最近应用程序列表中的Andr​​oid应用简历 [英] Android resume app from recent applications list

查看:199
本文介绍了最近应用程序列表中的Andr​​oid应用简历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图解决我的code中的错误,而且我希望有人能指出我在正确的方向。如果我的应用程序进入后台,并得到用户只需进入应用程序,然后选择我的应用程序恢复,一切工作正常。

I am trying to fix a bug in my code, and am hoping someone can point me in the right direction. If my app goes into the background, and gets resumed by the user just going into "apps" and selecting my app, everything works fine.

但是,如果把它放到后台,并通过按住home键,并从最近的应用程序列表中选择恢复它,我得到一个错误。我是IM pression下,这两个动作应做的确切的同样的事情?

However, if they put it into the background and resume it by holding down the home button, and selecting it from the recent apps list, I get a bug. I was under the impression these two actions should do the exact same thing?

有谁知道其中的差别是从应用程序的正常列表恢复应用程序,VS按住home键下来,然后从列表中选择它恢复它的?

Does anyone know what the difference is between resuming an app from the normal list of apps, vs resuming it by holding the home button down and then selecting the it from that list?

推荐答案

确切的答案取决于你的主屏幕启动的应用程序的执行位。不过,从我经历了那么远,我pretty确保...

The exact answer depends a bit on the implementation of your Home Screen or Launcher App. However, from what I experienced so far I'm pretty sure that ...


  1. ...的应用程序,这是从你的菜单或主屏幕开始通常由意图启动。为了更precise:活动启动程序显示在其菜单中有一个动作 android.intent.action.MAIN和类别所有活动android.intent.category.LAUNCHER ,如果你选择一个应用程序,它创建了一个意图并以此启动应用程序:

  1. ... apps, that are started from your menu or home screen are usually started by an Intent. To be more precise: the active launcher shows all activities in its menu that have an action android.intent.action.MAIN" and category android.intent.category.LAUNCHER and if you select an app, it creates an Intent and by this start the app:

Intent intent = new Intent(Launcher.context, SelectedActivity.class);
intent .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);  
startActivity(intent);

这从一些标志可能避免造成最有可能您启动的应用程序活动的新实例,除了这个(的android:launchMode =singleTop

This creates most likely a new instance of your started app activity, apart from some flags that might avoid this (android:launchMode="singleTop")

...看着<一个href=\"https://android.googlesource.com/platform/frameworks/base/+/621e17de87f18003aba2dedb719a2941020a7902/packages/SystemUI/src/com/android/systemui/recent/RecentApplicationsActivity.java\">recent 的任务就这样的工作方式不同,因为我可以看到:在任务列表依赖最有可能是由<一个创建的列表上href=\"http://developer.android.com/reference/android/app/ActivityManager.html#getRecentTasks%28int,%20int%29\">getRecentTasks()并且将所选应用前面。这可以通过使用<一来完成href=\"http://developer.android.com/reference/android/app/ActivityManager.html#moveTaskToFront%28int,%20int%29\">moveTaskToFront().只有当应用程序/活动已经完成了它的新创建(尝试杀死应用程序,你会看到它被重建)。

... looking at recent tasks this works differently as far as I could see: the task list relies most likely on a list that is created by getRecentTasks() and brings the selected app to front. This can be done by using moveTaskToFront(). Only if the app/activity has been finished it is newly created (try killing the app, and you'll see it is recreated).

结论:正如你所看到的近期任务列表中的工作有点像一个的(去)返回到应用程序的造成潜在的 onResume()而从菜单中启动应用程序将导致的onCreate()

Conclusion: as you can see the recent task list works rather like a (go) back to the app causing potentially an onResume() whereas starting the app from the menu will cause an onCreate().

请注意:一个应用程序包可能包含一个以上的应用程序。在通讯录的和的电话的应用在很多情况下,在一个提供的应用程序包(即APK文件)。

Note: one application package might contain more that one app. The Contacts and Phone app are in many cases just two different activities in one supplied application package (i.e. APK file).

希望这有助于了解不同的行为......干杯!

Hope this helps to understand the different behavior ... Cheers!

这篇关于最近应用程序列表中的Andr​​oid应用简历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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