此调用在以下位置完成onCreate
:
new retreive().execute();
该类asyncTask
如下所示:
class retreive extends AsyncTask<Void,Void,Void>{
ProgressDialog dialog = new ProgressDialog(busDisp.this);
@Override
protected void onPreExecute(){
this.dialog.setMessage("Retreiving Bus Routes...");
this.dialog.show();
this.dialog.setCancelable(false);
}
@Override
protected Void doInBackground(Void... arg0) {
busRouteJsonParsing();
this.dialog.dismiss();
return null;
}
@Override
protected void onPostExecute(Void voids){
setContentView(R.layout.buses);
stop1.setText(Integer.valueOf(stopsCtr[0]).toString()+" stops");
stop2.setText(Integer.valueOf(stopsCtr[1]).toString()+" stops");
stop3.setText(Integer.valueOf(stopsCtr[2]).toString()+" stops");
stop4.setText(Integer.valueOf(stopsCtr[3]).toString()+" stops");
dur1.setText(dur[0]);
dur2.setText(dur[1]);
dur3.setText(dur[2]);
dur4.setText(dur[3]);
this.dialog.dismiss();
}
onClicks
在这之后有8个PostExecute
这是日志:
12-20 19:55:57.701: E/WindowManager(982): Activity com.example.Try1.busDisp has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@418b7ad8 that was originally added here
12-20 19:55:57.701: E/WindowManager(982): android.view.WindowLeaked: Activity com.example.Try1.busDisp has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@418b7ad8 that was originally added here
12-20 19:55:57.701: E/WindowManager(982): at android.view.ViewRootImpl.<init>(ViewRootImpl.java:344)
12-20 19:55:57.701: E/WindowManager(982): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:267)
12-20 19:55:57.701: E/WindowManager(982): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
12-20 19:55:57.701: E/WindowManager(982): at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
12-20 19:55:57.701: E/WindowManager(982): at android.view.Window$LocalWindowManager.addView(Window.java:537)
12-20 19:55:57.701: E/WindowManager(982): at android.app.Dialog.show(Dialog.java:278)
12-20 19:55:57.701: E/WindowManager(982): at com.example.Try1.busDisp$retreive.onPreExecute(busDisp.java:249)
12-20 19:55:57.701: E/WindowManager(982): at android.os.AsyncTask.executeOnExecutor(AsyncTask.java:561)
12-20 19:55:57.701: E/WindowManager(982): at android.os.AsyncTask.execute(AsyncTask.java:511)
12-20 19:55:57.701: E/WindowManager(982): at com.example.Try1.busDisp.onCreate(busDisp.java:91)
12-20 19:55:57.701: E/WindowManager(982): at android.app.Activity.performCreate(Activity.java:4465)
12-20 19:55:57.701: E/WindowManager(982): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-20 19:55:57.701: E/WindowManager(982): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
12-20 19:55:57.701: E/WindowManager(982): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
12-20 19:55:57.701: E/WindowManager(982): at android.app.ActivityThread.access$600(ActivityThread.java:127)
12-20 19:55:57.701: E/WindowManager(982): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
12-20 19:55:57.701: E/WindowManager(982): at android.os.Handler.dispatchMessage(Handler.java:99)
12-20 19:55:57.701: E/WindowManager(982): at android.os.Looper.loop(Looper.java:137)
12-20 19:55:57.701: E/WindowManager(982): at android.app.ActivityThread.main(ActivityThread.java:4441)
12-20 19:55:57.701: E/WindowManager(982): at java.lang.reflect.Method.invokeNative(Native Method)
12-20 19:55:57.701: E/WindowManager(982): at java.lang.reflect.Method.invoke(Method.java:511)
12-20 19:55:57.701: E/WindowManager(982): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
12-20 19:55:57.701: E/WindowManager(982): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
12-20 19:55:57.701: E/WindowManager(982): at dalvik.system.NativeStart.main(Native Method)
我在第 249 行受到逼迫。