当你从最近的应用列表中刷一个android应用时,到底会发生什么?

当你从你的Android当前运行的应用程序列表中刷下一个应用程序时,应用程序和数据到底会发生什么变化?我们调查时请继续阅读。...

当你从最近的应用列表中刷一个android应用时,到底会发生什么?

当你从你的Android当前运行的应用程序列表中刷下一个应用程序时,应用程序和数据到底会发生什么变化?我们调查时请继续阅读。

今天的问答环节是由Android爱好者提供的,Android爱好者是Stack Exchange的一个分支,Stack Exchange是一个由社区驱动的问答网站分组。

问题

Android发烧友读者Eldarerathis对应用程序刷卡功能很好奇,它允许你通过home按钮调出正在运行的应用程序列表,然后向右刷卡,大概是为了关闭它们:

The recent apps list in Ice Cream Sandwich added the ability to swipe apps out of the list, thereby di**issing them permanently (and as far as I know this is a vanilla function, not a CM/custom ROM one). The documentation and platform highlights don’t appear to cover the under-the-hood workings of this functionality, but I’m curious to know what the system is actually doing.

Further adding to my curiosity, I decided to do a quick test: I started up Music on a CM9 install, then backed out of it. I then checked the recent apps list and saw it was indeed there (and in the proper state, based on the thumbnail). I then went into Settings->Applicati*** and force stopped the Music app, but it was still listed in the recent list, leading me to believe it’s not connected to processes lingering in the background.

Realizing now that Music may have been a poor choice, I also tested with the USA Today app. This exhibited basically the same behavior, and it seemed like it was forced to “relaunch” after the force stop (which makes sense) though the thumbnail in the recent apps list didn’t reflect this (cached, I’m guessing?).

So, what actually happens at the OS level when you swipe an app out of the recent list? Does it simply clear the app’s data out of RAM and garbage collect it, destroying its saved state?

当你从列表中刷下应用程序时到底发生了什么?

答案

Android爱好者贡献者Austin Mills提供了一些见解:

从最近的应用程序列表中刷出应用程序是普通的,是的,没有很好的文档记录。这一直是各种Android论坛上大量讨论的话题……这里的一些评论似乎最好地描述了这种共识:这种行为类似于关闭应用程序,但并不完全相同——一般来说(对于没有明确定义后退按钮处理的应用程序),这与回击次数足够多是一样的从应用程序中退出的次数。

这个链接有更多关于细节的细节,但是总体上你可以把它看作是退出应用程序。

我认为,对于音乐应用程序,它会启动服务,因此虽然任务本身(Music app/UI)可能关闭,但该服务仍在后台运行,这样您的音乐不会因为内存管理原因而突然停止。这可能影响到你所看到的。

随后,参加了问答圈的生活,埃尔达拉提斯带着自己的一些研究回来,总结出答案:

I appear to have found the magical search terms that led to some explanati*** from Google employees. Specifically, I found a couple of different places where Dianne Hackborn explains what happens when you swipe something out of the recent list. The first is a comment on one of her Google+ posts:

[W]hat specifically happens when you swipe away a recent task is it: (1) kills any background or empty processes of the application (see here for what this means), and (2) uses the new API to tell any services of the application about the task being removed so it can do whatever it thinks is appropriate.

She also notes in a blog comment:

Actually, removing an entry in recent tasks will kill any background processes that exist for the process. It won’t directly causes services to stop, however there is an API for them to find out the task was removed to decide if they want this to mean they should stop. This is so that removing say the recent task of an e-mail app won’t cause it to stop checking for e-mail.

If you really want to completely stop an app, you can long press on recent tasks to go to app info, and hit force stop there. Force stop is a complete kill of the app — all processes are killed, all services stopped, all notificati*** removed, all alarms removed, etc. The app is not allowed to launch again until explicitly requested.

So, it looks like the summary is that swiping an app out of the list will first kill all background processes for the app, then use onTaskRemoved to notify the app that the background task was removed. At that point it looks like it’s up to the app to decide what happens, so I guess there technically isn’t a hard-and-fast rule about what happens to the app beyond that point.


有什么要补充的解释吗?在评论中发出声音。想从其他精通技术的Stack Exchange用户那里了解更多答案吗?在这里查看完整的讨论主题。

  • 发表于 2021-04-11 17:07
  • 阅读 ( 155 )
  • 分类:互联网

你可能感兴趣的文章

你的iphone做了10件android做不到的事情

重申我们最近所说的,Android和iOS并不像很多年前那么不同。因此,即使两个智能**平台都有各自的优势和劣势,在两者之间做出选择也变得更加困难。 ...

  • 发布于 2021-03-12 04:11
  • 阅读 ( 223 )

程序员做的7件让用户发疯的蠢事

...员在为其创建应用程序时应该遵循的标准。例如,你希望Android应用程序看起来与iOS应用程序不同。这些都会随着时间的推移而改变!比较2012年和现在流行的Android应用。遵循指导原则,即使你的应用程序在视觉上不是最漂亮的,...

  • 发布于 2021-03-12 09:55
  • 阅读 ( 236 )

如何强制关闭android上无响应的应用程序

有一个应用程序在Android上没有响应吗?当你被困在一个冻结的应用程序上,而且似乎没有注册你的点击或刷卡时,这可能会让人沮丧。谢天谢地,关闭这些冻结的应用程序非常容易!下次发生这种情况时,请记住以下简单步骤...

  • 发布于 2021-03-13 07:33
  • 阅读 ( 337 )

如何设置你的新安卓手机

...卓**,恭喜你!您将体验世界上最流行的移动操作系统。Android可以让你定制你喜欢的设备的几乎任何方面,有一个漂亮的材料设计美学,并且有数百万个很棒的应用程序可以下载。 ...

  • 发布于 2021-03-14 22:21
  • 阅读 ( 236 )

android上最好的音乐播放器:谷歌播放音乐评论

对于在Android上播放音乐,谷歌播放音乐真的是无与伦比。其网络版本基本上取代了iTunes,其Android应用程序的作用类似iPhone的音乐应用程序。你可以播放你所有的本地音乐,流音乐从谷歌,流播客,还有更多。 ...

  • 发布于 2021-03-16 14:41
  • 阅读 ( 217 )

5个facebook应用程序,用于查找事件、地点、音乐、食谱或有趣的帖子

... 1facebook事件(web、ios、android):查找有趣的事件并与朋友进行社交 ...

  • 发布于 2021-03-17 03:44
  • 阅读 ( 233 )

如何在android手机和平板电脑上下载和更新应用程序

所以你对Android很陌生,想知道如何在Android上下载应用程序?在设置新设备之后,这是下一个合乎逻辑的步骤。 ...

  • 发布于 2021-03-24 12:33
  • 阅读 ( 345 )

android实现目标的5款最佳应用

... 以下是一些Android bucket list应用程序,它们将帮助你组织和实现你的人生目标。 ...

  • 发布于 2021-03-27 02:18
  • 阅读 ( 216 )

6款最适合从本地卖家那里购买廉价商品的移动应用程序

... 下载:OfferUp for Android | iOS(提供免费的应用内购买) ...

  • 发布于 2021-03-28 08:25
  • 阅读 ( 224 )

iphone上的应用程序剪辑是什么?你如何使用它们?

...用程序,验证安装它,启动它,然后可能还必须注册。 当你只是需要支付停车费或租自行车,这是不方便的。有了应用程序剪辑,由于您可以通过多种方式访问它们(无论是通过网络还是在现实世界中),整个过程都得到了简...

  • 发布于 2021-03-31 23:36
  • 阅读 ( 160 )
g04xxc46
g04xxc46

0 篇文章

相关推荐