开发者

Activity which downloads data in background with service and doesn't get destroyed on hitting back button

开发者 https://www.devze.com 2023-01-23 22:53 出处:网络
I need to develop an application with downloads the data at the background and update about the progress in the front.

I need to develop an application with downloads the data at the background and update about the progress in the front.

I guess this can be achieved using services and activity and passing data in between the. But, what I need to do is even if I hit back button and then start the activity again. It should 开发者_如何学JAVAcheck if the service is running or not. If service is not running it should start one else it should display the data from running service.

Something like music player where music is played by a service at a background and activity displays the information. Even on browsing through other activities of the application or hitting back, state of the music player is maintained.

Cheers, Prateek


Well Prateek,

Service can be started at any time you set & can be destroyed after you complete the task. For further help have a look @ http://developer.android.com/reference/android/app/Service.html#WhatIsAService .

0

精彩评论

暂无评论...
验证码 换一张
取 消