這是一個java文件做我的背景活動,在onPostExecute()我添加了一些意向開始,但它不工作,這樣的背景類只是一個Java文件它不是任何活動的Java文件onPostExecute()後,無法啓動新的意圖
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();
}
}
爲我的作品,謝謝 –