谁能帮我解决这个问题。在这里,我从服务中下载了数据,为此我使用了后台服务并显示了进度对话框。它在我的手机上完美运行,但相同的代码在我的平板电脑中出现问题:
这是我的代码:
public class BackgroundAsyncTaskForFirstTimeHitOrCacheExpired extends AsyncTask<String, Void, Boolean> {
public ProgressDialog dialog;
@Override
protected void onPreExecute() {
dialog = ProgressDialog.show(HomeActivity.this, "", "Downloading...", true);
}
@Override
protected Boolean doInBackground(String... arg0) {
//Download data
}
@Override
protected void onPostExecute(Boolean isServiceValuesFetchedSuccessfully) {
dialog.dismiss();
//activity started
}
}
这是我的 logcat 错误:
07-12 16:31:31.597: E/AndroidRuntime(2493): FATAL EXCEPTION: main
07-12 16:31:31.597: E/AndroidRuntime(2493): java.lang.IllegalArgumentException: View not attached to window manager
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.view.WindowManagerImpl.findViewLocked(WindowManagerImpl.java:385)
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.view.WindowManagerImpl.removeView(WindowManagerImpl.java:230)
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.view.Window$LocalWindowManager.removeView(Window.java:432)
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.app.Dialog.dismissDialog(Dialog.java:290)
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.app.Dialog.access$000(Dialog.java:78)
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.app.Dialog$1.run(Dialog.java:123)
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.app.Dialog.dismiss(Dialog.java:280)
07-12 16:31:31.597: E/AndroidRuntime(2493): at com.cpt.realtor.activity.HomeActivity$BackgroundAsyncTaskForFirstTimeHitOrCacheExpired.onPostExecute(HomeActivity.java:150)
07-12 16:31:31.597: E/AndroidRuntime(2493): at com.cpt.realtor.activity.HomeActivity$BackgroundAsyncTaskForFirstTimeHitOrCacheExpired.onPostExecute(HomeActivity.java:1)
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.os.AsyncTask.finish(AsyncTask.java:417)
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.os.AsyncTask.access$300(AsyncTask.java:127)
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.os.Handler.dispatchMessage(Handler.java:99)
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.os.Looper.loop(Looper.java:123)
07-12 16:31:31.597: E/AndroidRuntime(2493): at android.app.ActivityThread.main(ActivityThread.java:3687)
07-12 16:31:31.597: E/AndroidRuntime(2493): at java.lang.reflect.Method.invokeNative(Native Method)
07-12 16:31:31.597: E/AndroidRuntime(2493): at java.lang.reflect.Method.invoke(Method.java:507)
07-12 16:31:31.597: E/AndroidRuntime(2493): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
07-12 16:31:31.597: E/AndroidRuntime(2493): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
07-12 16:31:31.597: E/AndroidRuntime(2493): at dalvik.system.NativeStart.main(Native Method)
有人可以帮忙吗?
提前致谢。