【发布时间】:2017-08-09 11:25:33
【问题描述】:
这是一个用于执行我的后台活动的 java 文件,在 onPostExecute() 中我添加了一个启动意图,但它不起作用,这个后台类只是一个 java 文件,它不是任何活动的 java 文件
public class background extends AsyncTask<String,Void,String> {
private ProgressDialog dialog;
private ConnectivityManager cm;
String jsonurl, jsonstring;
mobile_form mform;
private Context context;
background (Context ctx){
this.context = context.getApplicationContext();
this.cm = (ConnectivityManager)ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
this.dialog = new ProgressDialog(ctx);
mform = new mobile_form();
}
@Override
protected void onProgressUpdate(Void... values) {
super.onProgressUpdate(values);
}
@Override
protected void onPostExecute(String result) {
context.startActivity(new Intent(context, mobile_form.class));
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null && activeNetwork.isConnectedOrConnecting();
if (isConnected) {
if (dialog.isShowing())
dialog.dismiss();
}
}
【问题讨论】:
标签: java android android-intent android-asynctask