Fixed MediaRouterPlayService being killed on screen rotate.
This commit is contained in:
parent
b016780fca
commit
5747680e6a
2 changed files with 15 additions and 8 deletions
|
@ -20,10 +20,17 @@
|
|||
android:label="@string/app_name"
|
||||
android:theme="@style/Theme.AppCompat.Light" >
|
||||
|
||||
<!--
|
||||
NOTE: configChanges is needed to avoid MediaRouterPlayService being
|
||||
killed on screen rotate. (why do you do this, Google???).
|
||||
This comes with some rendering issues on screen rotate (sometimes)
|
||||
on Android 4.4 (but that's not my error).
|
||||
-->
|
||||
<activity
|
||||
android:name="com.github.nutomic.controldlna.gui.MainActivity"
|
||||
android:label="@string/app_name"
|
||||
android:launchMode="singleTop" >
|
||||
android:launchMode="singleTop"
|
||||
android:configChanges="orientation|keyboardHidden|screenSize" >
|
||||
|
||||
<intent-filter android:label="@string/app_name" >
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ public class MediaRouterPlayService extends Service {
|
|||
|
||||
/*
|
||||
* Stops foreground mode and notification if the current route
|
||||
* has been removed.
|
||||
* has been removed. If the service is not bound, stops it.
|
||||
*/
|
||||
private MediaRouter.Callback mRouteRemovedCallback =
|
||||
new MediaRouter.Callback() {
|
||||
|
@ -117,6 +117,9 @@ public class MediaRouterPlayService extends Service {
|
|||
public void onRouteRemoved(MediaRouter router, RouteInfo route) {
|
||||
if (route.equals(mCurrentRoute))
|
||||
stopForeground(true);
|
||||
|
||||
if (!mBound)
|
||||
stopSelf();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -172,12 +175,8 @@ public class MediaRouterPlayService extends Service {
|
|||
*/
|
||||
@Override
|
||||
public boolean onUnbind(Intent intent) {
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
public void run() {
|
||||
if (!mPollingStatus && !mBound)
|
||||
stopSelf();
|
||||
}
|
||||
}, 5000);
|
||||
if (!mPollingStatus)
|
||||
stopSelf();
|
||||
mBound = false;
|
||||
return super.onUnbind(intent);
|
||||
}
|
||||
|
@ -342,6 +341,7 @@ public class MediaRouterPlayService extends Service {
|
|||
stop();
|
||||
if (!mBound)
|
||||
stopSelf();
|
||||
mPollingStatus = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue