为什么要使用启动活动? [英] Why Use Start Activities?

查看:239
本文介绍了为什么要使用启动活动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找通过API文档,并注意到先从API级别16的上下文类包括以下方法:

公共抽象无效startActivities(意向[]意图)

我一直在周围的Googling企图通过一个例子对延缓我好奇它在应用code,问题,或者文章使用,但我还没有碰到任何东西来作为呢。如果有人已经问过类似的问题,请让我知道。

不管怎么说,我很好奇,当这应该/可以应用code惯了,什么(如果有的话),这样做的好处是?我个人从来没有见过用这种方法,我不能把握它的效用。任何反馈将AP preciated。


解决方案

它很少在应用code使用

。我正想从来不说,但我不的的肯定;)

然而,它的可以的用于创建的合成的回栈,开始一个新的任务时。你想拥有一个现成的回堆栈,这样返回键导航层次这个任务里面。

奇怪的是,最好在<一个解释href=\"http://developer.android.com/reference/android/support/v4/content/ContextCompat.html#startActivities%28android.content.Context,%20android.content.Intent%5B%5D%29\"相对=nofollow> ContextCompat 的比上下文文档本身。


  

开始一系列的活动作为一个合成任务堆栈,要是能。


  
  

在API级别11(Android 3.0的/蜂窝)推荐的约定
  对于应用程序的导航使用改变了返回键。返回键的行为
  是本地的当前任务,不捕捉跨导航
  不同的任务。整个任务导航,轻松地到达
  previous任务是通过最近的用户界面,完成访问
  通过导航系统或随机提供的软件,最近通话键
  酒吧。在与旧的硬件按钮配置设备
  最近用过的用户界面可与Home键长preSS进行访问。


  
  

当从一个任务堆栈穿越到另一个后的And​​r​​oid 3.0中,
  应用程序应该合成回栈/历史新的任务,以便
  用户可以导航出了新的任务和回
  按后退键重复presses启动。返回键presses应
  整个任务堆栈不能导航。


  
  

startActivities提供了一种机制用于构造合成任务
  堆叠多个活动。如果基础API是不可用
  在系统上此方法将返回false。


I've been looking through the API documentation, and noticed starting with API level 16 the Context class includes the following method:

public abstract void startActivities (Intent[] intents)

I've been Googling around in attempts to stave my curiosity through an example's of it's use in application code, a question, or article, but I haven't come across anything as of yet. If someone has already asked a similar question, please let me know.

Anyways, I'm curious as to when this should/could be used in application code, and what (if any) benefits of doing so would be? I've personally never seen this method used, and I fail to grasp it's utility. Any feedback will be appreciated.

解决方案

It's rarely used in application code. I was going to say never, but I'm not that sure ;)

However, it can be used to create a synthetic back stack, when starting a new Task. You want to have a ready-made back stack, so that the back key navigates "hierarchically" inside this task.

Curiously, it's better explained in the documentation of ContextCompat than in Context itself.

Start a set of activities as a synthesized task stack, if able.

In API level 11 (Android 3.0/Honeycomb) the recommended conventions for app navigation using the back key changed. The back key's behavior is local to the current task and does not capture navigation across different tasks. Navigating across tasks and easily reaching the previous task is accomplished through the "recents" UI, accessible through the software-provided Recents key on the navigation or system bar. On devices with the older hardware button configuration the recents UI can be accessed with a long press on the Home key.

When crossing from one task stack to another post-Android 3.0, the application should synthesize a back stack/history for the new task so that the user may navigate out of the new task and back to the Launcher by repeated presses of the back key. Back key presses should not navigate across task stacks.

startActivities provides a mechanism for constructing a synthetic task stack of multiple activities. If the underlying API is not available on the system this method will return false.

这篇关于为什么要使用启动活动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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