今天弄项目时发现一个有趣的错误BUG,特来记载一下,初步定义为视图加载的问题,

错误信息先沾上来:

java.lang.RuntimeException: Unable to start activity ComponentInfo

java.lang.RuntimeException: Unable to start activity ComponentInfo

java.lang.RuntimeException: Unable to start activity ComponentInfo

android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@422dc6e8 is not valid; is your activity running?

at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:768)

Andrdoid用仿iphone的TabBar是用TabHost+ActivityGroup来解决的,里面用View堆栈的形式加载 Activity,在里面的Activity用AlertDialog对话框是,报异常:android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@422dc6e8 is not valid; is your activity running?

把AlertDialog里面的context:xxxActivity.this 改为::“xxxActivity.this..getParent()”就搞定!