A good Tipb article on platforms true multitasking

Chris Kerrigan

Well-known member
Nov 16, 2009
3,368
270
0
Visit site
No love lost for our sister site, but I have to respectfully disagree when it comes to the multitasking issue. Sure, iOS has always been able to play music in the background and browse the web/talk at the same time, but I don't consider that multitasking. When you close an app in iOS 4, it essentially puts it in a non-running hibernate state. It saves you current state, but that's it. *That* is my argument against it's multitasking abilities.

That's not the same with Android and WebOS. When apps are tossed into the background, they are (usually) still kept in an active state. The only time this differs is when Android's memory management kicks in and begins to prioritize tasks for better memory usage.
 

fangorious

Member
Oct 14, 2010
13
0
0
Visit site
That's not the same with Android and WebOS. When apps are tossed into the background, they are (usually) still kept in an active state. The only time this differs is when Android's memory management kicks in and begins to prioritize tasks for better memory usage.

That's incorrect. The lifecycle is such that when an activity loses focus the OS provides space for the app to save it's state (as a parameter to the onPause function) before the app gaining focus is given focus. Once an activity has no visible windows it is stopped (hopefully, but not for sure, calling the onStop function). If the user comes back to that instance of the activity the previously saved state is loaded. Although overloading onPause/onStop doesn't actually guarantee saving your state. You actually need to use onSaveInstanceState, which isn't even documented in the lifecycle flowchart. This is why on devices with low memory (the original MyTouch 3G for example), when you switch from the browser to another app and then back to the browser it usually loads your homepage instead of the page you were on but on the current 512+ MB of RAM devices it all actually works. Because there's enough memory to go around maintaining the saved state bundles.
 

Joelist

Well-known member
Apr 23, 2010
349
30
0
Visit site
Here's an interesting one. I can get in a car and start travelling a route using Google Navigation (or the VZW one for that matter). While it is running I can (I tested this) go open other apps (like the Browser) and browse, compose email and so forth. When I go back to the Navigation it has me at the exact correct place on the route immediately (no delay or reacquisition). The only way that can be happening is if it is still running in the background.
 

fangorious

Member
Oct 14, 2010
13
0
0
Visit site
The confusion comes from the generic use of the word application. I was speaking specifically about an Activity, which is one of several things that can be distributed with an apk. An Activity is the interactive UI that usually has a launcher in the App drawer (Music, Pandora, Maps). For navigation the apk has a background Service (ie it does not interact directly with the user and is memory resident, there are no windows to maintain focus or visibility) and an Activity (ie the interactive map view that shows your position and outlines the route on the map). Activities are what users interface with and generally refer to as applications. They are no more multi-tasking enabled than on iOS. When they are not visible, they save their state to memory and the process goes away. Start a game of Angry Birds, get into one of the levels, hit Home, and then hit Menu -> Settings -> Applications -> Manage Applications -> Running, no Angry Birds. Start Angry Birds again and it should resume at the level you were in, with your current progress maintained. (At least that's what I see on my Nexus S). A background service (like the music player, or pandora, or the navigation service playing audio driving directions) stays memory resident in the background but you never interact with it directly. You use an Activity like Music to tell the background service what to do. Or the Map Activity to tell the Navigation Service to load up a route, monitor your GPS and speak directions to you. I should have clarified that distinction. Apps do not get "tossed into the background". If an apk needs to continue processing without a visible Activity window they include a Service. A running "application" can be made of a stack of Activities and Services from a plethora of different apks, so the notion of a single application somewhat breaks down in this respect. Telenav could have their navigation Service advertise itself and the Google Map Activity could then be made to let you select from all advertised navigations Services.

The way that iOS and Android handle multitasking really isn't all that difference under the hood except on iOS you have to be really special to get to write your own background service but on Android anybody can play. So yes, in the end, there is more multi-tasking allowed on Android. But technically speaking, it doesn't really have a better implementation.
 

Joelist

Well-known member
Apr 23, 2010
349
30
0
Visit site
The confusion comes from the generic use of the word application. I was speaking specifically about an Activity, which is one of several things that can be distributed with an apk. An Activity is the interactive UI that usually has a launcher in the App drawer (Music, Pandora, Maps). For navigation the apk has a background Service (ie it does not interact directly with the user and is memory resident, there are no windows to maintain focus or visibility) and an Activity (ie the interactive map view that shows your position and outlines the route on the map). Activities are what users interface with and generally refer to as applications. They are no more multi-tasking enabled than on iOS. When they are not visible, they save their state to memory and the process goes away. Start a game of Angry Birds, get into one of the levels, hit Home, and then hit Menu -> Settings -> Applications -> Manage Applications -> Running, no Angry Birds. Start Angry Birds again and it should resume at the level you were in, with your current progress maintained. (At least that's what I see on my Nexus S). A background service (like the music player, or pandora, or the navigation service playing audio driving directions) stays memory resident in the background but you never interact with it directly. You use an Activity like Music to tell the background service what to do. Or the Map Activity to tell the Navigation Service to load up a route, monitor your GPS and speak directions to you. I should have clarified that distinction. Apps do not get "tossed into the background". If an apk needs to continue processing without a visible Activity window they include a Service. A running "application" can be made of a stack of Activities and Services from a plethora of different apks, so the notion of a single application somewhat breaks down in this respect. Telenav could have their navigation Service advertise itself and the Google Map Activity could then be made to let you select from all advertised navigations Services.

The way that iOS and Android handle multitasking really isn't all that difference under the hood except on iOS you have to be really special to get to write your own background service but on Android anybody can play. So yes, in the end, there is more multi-tasking allowed on Android. But technically speaking, it doesn't really have a better implementation.

But that does not fully account for my Navigation example. If what you are saying is right the Navigation app should experience a slight lag when reopened as the UI "catches up" to the GPS. It does not do that, but rather is exactly in the right spot immediately. Therefore there must be a third "multitask type" where the Activity and Service both run in the background.
 

fangorious

Member
Oct 14, 2010
13
0
0
Visit site
The usual lag when opening Maps is the time it takes for GPS to obtain a lock on your position and possibly to download the map images if they're not cached. Since the background service is using the GPS antenna the whole time your location is known (otherwise it couldn't speak out directions relevant to your location) without waiting for the GPS antenna to turn on and locate satellites. In the current release of Maps the map data is cached so as long as you don't travel outside the geographic location that has data cached there will be no lag time to download the new map. If you begin navigating a route, hit the home button, then drive 150 miles to a different city, you may notice a lag downloading the maps for the new location (With Google Maps at least, Telenav keeps the map data local on your SD card so there's no data usage).

We're really in agreement that it's a better user experience, because on Android I have a wider selection of what can be done in the background. I'm just being a bit of a douche about the details, because there's nothing but corporate policy getting in the way of iOS developers being able to do the same things.
 

RUSH

Well-known member
Dec 6, 2010
4,120
285
0
Visit site
I personally don't like the fact that I can't listen to music while browsing the web on Android. I'm sure one day this will be a possibility.
 

Joelist

Well-known member
Apr 23, 2010
349
30
0
Visit site
I personally don't like the fact that I can't listen to music while browsing the web on Android. I'm sure one day this will be a possibility.

Strange. I just did exactly that. Browsed several uncached websites while listening to music.
 

Guamguy

Well-known member
Dec 28, 2010
93
2
0
Visit site
iOS apps don't do periodic interval syncs on the background, although they do push notifications. Android apps do periodic interval syncs.

An example is Pulse News Reader. The Android version can do period updates, with the update intervals set by the user. The iOS version cannot.

How Android does this? Android apps have something called Services. Basically if an app is closed, you only close its main interface component (Activity). The Service still runs on the background. That's why if you pull up one of the task managers, you can see a lot of processes for apps you didn't launch. They're just services, without any interface, and you can't jump into them and operate the app.

Not exactly related to multitasking, but iOS only appropriates a single thread for downloading. Try updating 10 apps at once, they all get queued, and each app is downloaded and installed sequentially. On Android, if you update 10 apps, all ten get a separate thread.
 

Trending Posts

Forum statistics

Threads
943,148
Messages
6,917,517
Members
3,158,847
Latest member
fallingOutOfLoveWfithTech