android 點擊home鍵,再點擊app icon,app重啓

第一種解決辦法:
查看AndroidManifest.xml種LAUNCHER Activity中是否有android:launchMode=“singleTask”,有的話去掉
第二種解決方法:
如果還不行的話,在引導頁的onCreate方法中加入

 //防止點擊home鍵,再點擊圖標,重啓的bug
        if (!isTaskRoot())
        {
            final Intent intent = getIntent();
            final String intentAction = intent.getAction();
            if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN))
            {
                finish();
                return;
            }
        }

放在 setContentView();之前

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