开发者

Android : launch mode for activities

I have multiple activities in my application . The flow for activities is

A->B->C...

A->D->E...

A->F->G..

....

And each has a back button to go back to previous activity and home to go back to A.

My question is when i launch each of these as singletask, i can visible feel fast switching between activities when i click back or home. I dont see any issues 开发者_StackOverflowif i keep them as singletask.

BUt are there any issues that i am verlooking if i keep the activities as singletask in my application. Thanks a lot for your time and help


Yes there are issues in changing the behaviour mode of activity from mainfest.xml, When you will press the home button for android home screen and get back to the application the previous activity will be gone and will finish the application, then better is to use intent instead using single task mode, you can use flags with intent to cleat the activity stacks..and by launching the mode in single task you are changing the systems settings, why dont you keep the launch mode and give it to system for handling the activities..!

Intent intent = new Intent(getApplicationContext(),A.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(intent);
            finish();


A "standard" or "singleTop" activity can be instantiated many times. They can belong to multiple tasks, and a given task can have multiple instances of the same activity.  In contrast, "singleTask" and "singleInstance" activities are limited to just one instance. Since these activities are at the root of a task, this limitation means that there is never more than a single instance of the task on the device at one time.

The clearTaskOnLaunch attribute If this attribute is set to "true" in the root activity of a task, the stack is cleared down to the root activity whenever the user leaves the task and returns to it. In other words, it's the polar opposite of alwaysRetainTaskState(which u can use if u want to retain all activities in a stsck). The user always returns to the task in its initial state, even after a momentary absence or even after pressing home in ur case.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜