相关疑难解决方法(0)

Android:ProgressDialog.show()与getApplicationContext崩溃

我似乎无法理解为什么会这样.这段代码:

mProgressDialog = ProgressDialog.show(this, "", getString(R.string.loading), true);
Run Code Online (Sandbox Code Playgroud)

工作得很好.但是,这段代码:

mProgressDialog = ProgressDialog.show(getApplicationContext(), "", getString(R.string.loading), true);
Run Code Online (Sandbox Code Playgroud)

抛出以下异常:

W/WindowManager(  569): Attempted to add window with non-application token WindowToken{438bee58 token=null}.  Aborting.
D/AndroidRuntime( 2049): Shutting down VM
W/dalvikvm( 2049): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
E/AndroidRuntime( 2049): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime( 2049): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.tastekid.TasteKid/com.tastekid.TasteKid.YouTube}: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
E/AndroidRuntime( 2049):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2401)
E/AndroidRuntime( 2049):    at …
Run Code Online (Sandbox Code Playgroud)

android progressdialog

108
推荐指数
6
解决办法
14万
查看次数

标签 统计

android ×1

progressdialog ×1