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();之前

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