android singleTop 不起做用

今天,排查問題,發現設置了singleTop 的activity, 屢次啓動依然是多個acitivity,而不是一個。
明明在清單裏面設置了,可是就是啓動了多個。
多是由於啓動的太快,致使系統判斷有錯誤吧。this

固然,也能夠本身作一個計數,啓動屢次的話,就return,也能夠把啓動模式在代碼裏面改成sigletaskspa

Intent intent = new Intent(ActivityBase.this, AppActivity.class);

                    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP);
                    startActivity(intent);

這樣就保證了,只會有一個。code

相關文章
相關標籤/搜索