Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
347 views
in Technique[技术] by (71.8m points)

android - FLAG_ACTIVITY_NEW_TASK clarification needed

So my problem is:

  • I start App1, open Screen1 and then Screen2.
  • I press Home, leaving App1 in the background.
  • I open App2, start App1.Screen1 with FLAG_ACTIVITY_NEW_TASK, expecting to be on App1.Screen2 in the previously left task. Instead Im on App1.Screen1 and the system called onNewIntent().

When I press back it brings Sceen2 and Screen1 again. I dont use any other intent flags or launch modes.

Could someone explain what's happening??

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Android has TONS of bugs related to activities and tasks.

Nevertheless, Google changed the behavior of tasks between OS versions and didn't notify the developers, which is the most annoying thing about it.

jakk - If you didn't set any flags on the activities (A or B), than the behavior you are describing is WRONG.

And for all the ones which say that there is no problem with the documentation, try this:

  1. Create an application with Activity A (launching activity) & B (with the default launch mode for both).
  2. Start the application - a task is created with activity A only.
  3. From a button in activity A, launch activity B with a FLAG_ACTIVITY_NEW_TASK.
  4. Click the button several times and you'll see that activity B is created multiple times inside the task, which is NOT as the documentation says.

There are more scenarios to prove that the documentation is BAD / WRONG.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...