Kas tieši notiek, pārlūkojot Android lietotni no jaunāko lietotņu saraksta?

Satura rādītājs:

Kas tieši notiek, pārlūkojot Android lietotni no jaunāko lietotņu saraksta?
Kas tieši notiek, pārlūkojot Android lietotni no jaunāko lietotņu saraksta?

Video: Kas tieši notiek, pārlūkojot Android lietotni no jaunāko lietotņu saraksta?

Video: Kas tieši notiek, pārlūkojot Android lietotni no jaunāko lietotņu saraksta?
Video: Microsoft password reset: How to reset forgotten Microsoft account password in windows 10/laptop pc - YouTube 2024, Aprīlis
Anonim
Vai, pavelkot lietotni ārpus savas pašreiz notiekošo lietotņu saraksta Android, kas precīzi notiek ar lietojumprogrammu un datiem? Lasiet tālāk, kā mēs izmeklējam.
Vai, pavelkot lietotni ārpus savas pašreiz notiekošo lietotņu saraksta Android, kas precīzi notiek ar lietojumprogrammu un datiem? Lasiet tālāk, kā mēs izmeklējam.

Šodienas jautājumu un atbilžu sesija mums priecājas ar Android entuziastu - Stack Exchange dalību, kas ir kopiena, kuras pamatā ir Q & A tīmekļa vietnes.

Jautājums

Android entuziastu lasītājs Eldarerathis ir interesanti par lietotņu pārlūkošanas funkcionalitāti, kas ļauj pārlūkot jūsu veikto lietotņu sarakstu, izmantojot mājas pogu, un pēc tam velciet tos pa labi, iespējams, tos aizverot:

The recent apps list in Ice Cream Sandwich added the ability to swipe apps out of the list, thereby dismissing 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->Applications

un spēks pārtrauca lietotni Mūzika, taču tas joprojām tika iekļauts nesenajā sarakstā, un man lika domāt, ka tas nav saistīts ar procesiem, kas notiek fonā.

Tagad, apzinoties, ka mūzika, iespējams, bija slikta izvēle, es arī testēju ar lietotni USA Today. Tas izrādījās pamatā tādā pašā uzvedībā, un šķita, ka pēc spēka pārtraukšanas tā bija spiesta atsākt spēli (kas ir jēga), lai gan pēdējo lietotņu saraksta sīktēls to neatspoguļoja (kešatmiņā es domāju?).

Tātad, kas faktiski notiek OS līmenī, ja velciet lietotni no neseno saraksta? Vai tas vienkārši attīra app datus no RAM un atkritumi savāc to, iznīcinot tā saglabāto stāvokli?

Kas precīzi notiek, pavelkot lietotni no saraksta?

Atbildes

Android entuziastu veidotājs Austin Mills piedāvā ieskatu:

No jaunāko lietotņu saraksta lietojamo programmu velkšana ir vaniļa, un jā, nav labi dokumentētas. Tas ir bijis cienīgs diskusiju temats par dažādiem Android forumiem … visticamāk, vislabāk ir aprakstīts, ka konsenss dažos komentāros ir aprakstīts, ka uzvedība ir līdzīga, bet ne pilnīgi tāpat kā lietotnes slēgšana - vispār (lietotnēm, kas nenosakiet skaidru atpakaļ pogu apstrādi), tas ir tas pats, kas pietrūkst pietiekami daudz laika no programmas, kuru jūs izietat no tā.

Saite satur detalizētāku informāciju par specifiku, bet kopumā jūs to varat domāt kā pieteikuma atstāšanu.

Īpaši mūzikas lietotnei es uzskatu, ka tā sāk pakalpojumu, tāpēc, ka pats uzdevums (mūzikas lietotne / lietotāja saskarne) var tikt aizvērts, pakalpojums turpina darboties fonā, lai jūsu mūzika netiktu pietuvināta tikai tāpēc, ka uzdevums tika iztīrīti atmiņas pārvaldības dēļ. Tas var ietekmēt to, ko jūs redzējāt.

Tad, piedaloties dzīvības jautājumu un atbilžu lokā, Eldarerathis atgriezās ar kādu savu pētījumu, lai noapaļotu atbildi:

I appear to have found the magical search terms that led to some explanations 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 notifications 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

paziņot lietotnei, ka fona uzdevums ir noņemts. Tajā brīdī izskatās, ka lietotnei ir jāizlemj, kas notiek, tāpēc es domāju, ka tas ir tehniski nav grūti un ātri noteikumi par to, kas notiek ar lietotni ārpus šī punkta.

Vai kaut ko pievienot paskaidrojumam? Skatieties komentāros. Vēlaties lasīt citas atbildes no citiem tehnoloģiju savvy Stack Exchange lietotājiem? Šeit skatiet pilnu diskusiju pavedienu.

Ieteicams: