Issue
I have created an app where I use two activities such that:
1st Activity is Main Activity, & 2nd Activity starts from Main Activity using a Button.
Now I have started a sound(using service) in Main activity and want to keep that service alive as long as my app is alive but want to stop is if it app closes(by either pressing back button or Home button).
The problem is that when I use onPause/onResume methods then sound service stops when I start 2nd Activity.
Anyone having any idea how to tackle it? Thanks in advance!
Solution
Instead of using onResume()
and onPause()
, use onUserLeaveHint()
.
When you call the other Activity add this to your Intent
:
intent.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION);
You can read more about it here: http://developer.android.com/reference/android/app/Activity.html#onUserLeaveHint%28%29
Answered By - EyalBellisha
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.