问题描述
我发现很难了解确切的情况,其中每个不同的启动模式将在Android中使用。谁能给我提供一些例子来帮助理解,当各种各样的方式是适当的?
I am finding it hard to understand the exact circumstances in which each the various launch modes would be used in Android. Could anyone provide me with some examples to help understand when the various modes are appropriate?
推荐答案
之间的<一个href="http://android.git.kernel.org/?p=platform/packages/apps/Browser.git;a=blob;f=AndroidManifest.xml;h=3d970ab3984bb06057a6ca756cb59b7738581967;hb=HEAD">Browser和<一href="http://android.git.kernel.org/?p=platform/packages/apps/AlarmClock.git;a=blob;f=AndroidManifest.xml;h=d7310097bf2c247314ec1aa38ffaa7da952e6fa0;hb=HEAD">Alarm时钟应用程序,涵盖所有四个发射模式:
Between the Browser and Alarm Clock applications, you cover all four launch modes:
-
<一个href="http://android.git.kernel.org/?p=platform/packages/apps/Browser.git;a=blob;f=src/com/android/browser/BrowserActivity.java;h=60dffac9e075748a01d8d761d087bbbcb687b9d0;hb=HEAD">BrowserActivity使用 singleTask 。只有一次一个浏览器的活性和它不会成为该发送它的Intent打开网页部分任务。虽然它可能返回到任何最近推出了它,当你打回它实际上是固定在了自己的任务活动栈底。它将与它推出如书签活动分享自己的任务。
BrowserActivity uses singleTask. There is only one browser activity at a time and it doesn't become part tasks that send it intents to open web pages. While it might return to whatever most recently launched it when you hit back it is actually fixed at the bottom of its own task activity stack. It will share its task with activities that it launches like bookmarks.
<一个href="http://android.git.kernel.org/?p=platform/packages/apps/Browser.git;a=blob;f=src/com/android/browser/BrowserBookmarksPage.java;h=6ab011bfadd147f430050e174c8b86eb33299c97;hb=HEAD">BrowswerBookmarksPage使用 singleTop 。虽然可以有这个活动的多个实例,如果已经有一个在任务的活动堆栈顶部它将被重新使用和<$c$c>onNewIntent()$c$c>将被调用。这样,您只需打回来一次,如果书签活动开始多次返回到浏览器。
BrowswerBookmarksPage uses singleTop. While there can be multiple instances of this activity, if there is already one at the top of the task's activity stack it will be reused and onNewIntent()
will be called. This way you only have to hit back once to return to the browser if the bookmarks activity is started multiple times.
<一个href="http://android.git.kernel.org/?p=platform/packages/apps/AlarmClock.git;a=blob;f=src/com/android/alarmclock/AlarmClock.java;h=75477fd01568d438c543facb34e8f8c877459611;hb=HEAD">AlarmClock使用标准。用户可以启动该活动的多个实例,并且这些实例可以是任何任务中的活动的任何地方栈的一部分。作为一个相当简单的应用程序并不真正需要它的活动严格控制。
AlarmClock uses standard. The user can launch multiple instances of this activity and these instances can be part of any task and anywhere in the activity stack. As a fairly simple application it doesn't really demand tight control of its activity.
<一个href="http://android.git.kernel.org/?p=platform/packages/apps/AlarmClock.git;a=blob;f=src/com/android/alarmclock/AlarmAlert.java;h=89a866a991ebecce2a0114f2d5c3f08c378ff826;hb=HEAD">AlarmAlert使用 singleInstance 。仅一次一个它警报活动,并且总是它自己的任务。任何它启动(如果有的话)成为自己的新任务的一部分。
AlarmAlert uses singleInstance. Only one alert activity at a time and it is always its own task. Anything it launches (if anything) becomes part of its own new task.
这篇关于对于Android发射模式的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!