Php Android-任务完成后的下一个活动

Php Android-任务完成后的下一个活动,php,android,android-intent,android-activity,Php,Android,Android Intent,Android Activity,我一直在尝试创建一个简单的应用程序来发布到PHP服务器。我想创建一个类,它可以处理所有post请求,然后将数据返回到原始活动 目前,我有一个名为ConectionHandler的类,它被设计用来处理所有Post请求 public class ConnectionHandler extends AsyncTask<String, Void, String> { public ConnectionHandler(ArrayList targetList, ArrayList dataL

我一直在尝试创建一个简单的应用程序来发布到PHP服务器。我想创建一个类,它可以处理所有post请求,然后将数据返回到原始活动

目前,我有一个名为ConectionHandler的类,它被设计用来处理所有Post请求

public class ConnectionHandler extends AsyncTask<String, Void, String> {

public ConnectionHandler(ArrayList targetList, ArrayList dataList, String hostLocation){
    ...
}

protected String doInBackground(String... params){
    ...
    return returnData;
}
公共类ConnectionHandler扩展异步任务{
公共连接处理程序(ArrayList targetList、ArrayList dataList、String hostLocation){
...
}
受保护的字符串doInBackground(字符串…参数){
...
返回数据;
}
我一直在从我的loginActivity创建一个对象ConnectionHandler。一旦我在doInBackground方法中收到数据,我希望它返回loginActivity,以便我可以处理它并启动一个新的活动


有什么简单的方法可以做到这一点吗?我已经尝试了许多不同的想法,但到目前为止似乎都不管用。

您是否尝试过在AsyncTask中使用onPostExecute方法?当您从doInBackground返回值时,它将被发送到在主UI线程上运行的onPostExecute

public class ConnectionHandler extends AsyncTask<String, Void, String> {

    public ConnectionHandler(ArrayList targetList, ArrayList dataList, String hostLocation){
        ...
    }

    protected String doInBackground(String... params){
        ...
        return returnData;
    }

    @Override
    protected void onPostExecute(String result) {
       //do whatever you want with the data here 
    }    
}
公共类ConnectionHandler扩展异步任务{
公共连接处理程序(ArrayList targetList、ArrayList dataList、String hostLocation){
...
}
受保护的字符串doInBackground(字符串…参数){
...
返回数据;
}
@凌驾
受保护的void onPostExecute(字符串结果){
//你想用这里的数据做什么就做什么
}    
}

我确实试过了。我不知道如何为“getApplicationContext”之类的东西引用loginActivity。有什么方法可以让它工作吗?那么你对上下文有问题吗?你可以通过构造函数将它传递给异步任务。我可以从onPostExecute方法启动一个intent吗?我一直在尝试这样做,但我不知道作为第一个参数传递什么。如果有方法可以做到这一点,那将比使用应用程序要好得多n上下文。谢谢!请尝试CurrentActivity。这是第一个参数,其中CurrentActivity是您所在活动的名称