Android日常知識收集與總結之對話框異常

今天弄項目時發現一個有趣的錯誤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()”就搞定!


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章