views:

47

answers:

2

Hi

i am working on an application that send and get data from internet each 5 min

if i press home key and my app goes to background... it will still continue sending/getting data from internet? or i have to do something special?

thanks

A: 

"If an activity is completely obscured by another activity, it is stopped. It still retains all state and member information, however, it is no longer visible to the user so its window is hidden and it will often be killed by the system when memory is needed elsewhere. If an activity is paused or stopped, the system can drop the activity from memory by either asking it to finish, or simply killing its process. When it is displayed again to the user, it must be completely restarted and restored to its previous state."

http://developer.android.com/reference/android/app/Activity.html#ActivityLifecycle

Cameron
a background service trhead??? what you mean with that??
AndroidUser99
more info:http://developer.android.com/guide/topics/fundamentals.html#acttaskRead about the stack, how opening multiple applications are handled and activity lifecycle for a complete picture
Cameron
don't worry about background services for now. Short answer is yes the home button puts your app in the background and it keeps running
Cameron
ok then it keeps running? 100% sure?i read this on android developers guide notifications section: "Because an Activity can perform actions only while it is active and in focus, you should create your status bar notifications from a Service"it says that when an application is in background it doesn't do actions... are u sure that yes it do?
AndroidUser99
It sounds to me like you want to have a background service. This way 100% for sure it will run in the background and transmit data.http://developer.android.com/reference/android/app/Service.html
Cameron
and if i dont use that way and just make a normal application? my application it's simply a normal application, but it needs to continue executing when it is in background...
AndroidUser99
That's not a normal application then
Falmarri
A: 

No. Activities shouldn't be depended on to process tasks in the background.

The following link illustrates the fundamentals of different Android components and what they do, i.e. the "parts" of an app.

You should be using a Service for background processing.

From what you're saying, I'd suggest an IntentService fired by an Alarm.

Application Fundamentals

Android Dev Dude
i have to transform all my main intent into a service then?
AndroidUser99