android - 使用 AsyncTask onPostExecute 链接到新 Activity ?

标签 android android-asynctask

我在将主页链接到其他页面时遇到问题。我已经搜索并运行了此处已询问的所有问答,但有错误。 有人可以帮助我吗..它非常有用.. tq

public class BackgroundTask extends AsyncTask<String,Void,String>
{
AlertDialog alertDialog;
ProgressDialog progressDialog;
Context ctx;
BackgroundTask(Context ctx)
{
    this.ctx=ctx;
}

@Override
protected void onPreExecute()
{
    alertDialog= new AlertDialog.Builder(ctx).create();
    alertDialog.setTitle("Login Information...");
}

@Override
protected String doInBackground(String... params)
{
    String login_url="http://10.0.2.2/webapp/login.php";
    String method = params[0];
}

@Override
protected void onProgressUpdate (Void... values)
{
    super.onProgressUpdate(values);
}

这是部分...

@Override
protected void onPostExecute (String result)
{

    alertDialog.setMessage(result);
    alertDialog.show();

     //Want to go new activity page`enter code here`

}
}

已经试过了,但是不行。

Intent intent = new Intent(MyAsyncTaskActivity.this, NextActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
getApplicationContext().startActivity(intent);

最佳答案

    Intent intent = new Intent(ctx, NextActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //optional
    ctx.startActivity(intent);

关于android - 使用 AsyncTask onPostExecute 链接到新 Activity ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32839021/

相关文章:

java - 将独特的图像添加到 android 中的微调行

android - 如何在异步任务完成之前停止执行 UI 线程以返回在 android 中的 AsyncTask 中获得的值

android - 当其他任务正在运行时,AsyncTask 永远不会完成

java - 使用 AsyncTask 在后台创建一个 GLSurfaceView

java - "silently"的 Android 进程使用刷新 token 获取新的访问 token

java - Android:如何在主要 Activity 的变量中存储值(value)?

android - 导入带有IntelliJ资源的android支持库

android - Listview 中的左右对齐行?

java - 无法删除路径

android - 同时使用 setOnItemClickListener 和 setOnItemLongClickListener 两个监听器同时触发或同时工作。为什么