0

I have been reading about services and how to use them, but I need some advice.

Currently I have an app which has a MainActivity with a setContentView which sets up the main menu. And there are some buttons which then start other activities.

So you have MainActivity -> Activity A -> Activity B -> Activity C

And after going through the app I have it so onBackPress finish() is called and you can go back to the main menu.

From what I understand an Android application must run an activity on launch?

So if I am to implement a service, I have to start an activity and then run a service from that activity.

I want my app to use a service so it isn't a background/cached process when the user clicks the Home button.

So how should I approach this?

I was thinking that I could have an activity that has a sole purpose of creating a Service, and then I could have that service launch the MainActivity?

If that is how I should go about it, once the user navigates back to the Main Activity, will executing finish() exit the app? I would think not .. so how would I kill the service that begun the Main Activity?

2
  • Can you tell me a little more about what you are trying to accomplish with the service? Is it to consume web services and transfer some data via JSON?
    – MobileMon
    May 1, 2014 at 12:23
  • It just plays mp3's the app that is. I want it as a service, so it is visible when they click the home button in the running apps. Otherwise they have to show the cached/background processes to exit it. May 1, 2014 at 12:56

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.