如何在Android中使用意图标志? [英] How to use Intent Flags in android?

查看:62
本文介绍了如何在Android中使用意图标志?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解各种意图的标志,但无法在我的活动中使用.谁能解释我,

I have the knowledge of different types of flags in intent but unable to use in my activities. Can anybody explain me,

  • 我们怎样才能完成一项活动?或者
  • 如何在意图标志的帮助下操作活动堆栈.

推荐答案

我们如何完成一项活动,或者如何?

要完成活动,您需要手动调用finish()方法或按本身称为finish()方法的后退按钮.

To finish an activity you need to call finish() Method of activity either manually or press back button which itself calls finish() method.

我猜您在问有关Android启动模式的信息,该模式也可以使用Intent标志声明,例如:

I guess you are asking about Android launch mode that can also be declared using the Intent flags, such as :

1)FLAG_ACTIVITY_NEW_TASK -如果已设置,则此活动将成为此历史记录堆栈上新任务的开始.任务(从启动该任务的活动到下一个任务活动)定义了用户可以移动到的一系列原子活动.任务可以移到前台和后台;特定任务中的所有活动始终保持相同的顺序.

1) FLAG_ACTIVITY_NEW_TASK - If set, this activity will become the start of a new task on this history stack. A task (from the activity that started it to the next task activity) defines an atomic group of activities that the user can move to. Tasks can be moved to the foreground and background; all of the activities inside of a particular task always remain in the same order.

2)FLAG_ACTIVITY_CLEAR_TOP -如果已设置,并且正在启动的活动已在当前任务中运行,则代替启动该活动的新实例,将所有其他活动置于其之上将会关闭,并且该Intent将作为新Intent交付到(现在位于顶部)旧活动.

2) FLAG_ACTIVITY_CLEAR_TOP - If set, and the activity being launched is already running in the current task, then instead of launching a new instance of that activity, all of the other activities on top of it will be closed and this Intent will be delivered to the (now on top) old activity as a new Intent.

3)FLAG_ACTIVITY_SINGLE_TOP -如果已设置,则该活动如果已在历史记录堆栈的顶部运行,则不会启动.

3) FLAG_ACTIVITY_SINGLE_TOP - If set, the activity will not be launched if it is already running at the top of the history stack.

有关Intent的更多信息,请访问 Android开发者网站.

More information of Intents is available in Android Developers website.

此外,您还可以在此链接中阅读带有示例的详细说明. >.

Also you can read a detailed description with examples in this link.

如何借助Flags操作活动堆栈.

对后堆栈的操作取决于您的要求,例如如果您希望以后在应用程序启动后看到某个活动,则可以将其保留在堆栈中.导航到其他屏幕时,只需完成一次被称为启动"屏幕的操作即可.

Manipulation of back stack depends on your requirement for e.g. if you want you see a certain activity later on after application starts then you can keep it in back stack Also if you do not want to see a definite screen for e.g. splash screen which is called only once needs to be finished while navigating to other screen.

这篇关于如何在Android中使用意图标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆