Android Services and Android LifeCycle handling -


i have created app use 2 activities such that:

1st activity main activity, & 2nd activity starts main activity using button.

now have started sound(using service) in main activity , want keep service alive long app alive want stop if app closes(by either pressing button or home button).

the problem when use onpause/onresume methods sound service stops when start 2nd activity.

anyone having idea how tackle it? in advance!

instead of using onresume() , onpause(), use onuserleavehint(). when call other activity add intent:

intent.addflags(intent.flag_activity_no_user_action); 

you can read more here: http://developer.android.com/reference/android/app/activity.html#onuserleavehint%28%29


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -