Prevent onServiceConnected ClassCastException
This commit is contained in:
parent
1048735327
commit
eca8fc90b8
|
@ -196,11 +196,12 @@ public class PlayerWidgetService extends Service {
|
||||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||||
Log.d(TAG, "Connection to service established");
|
Log.d(TAG, "Connection to service established");
|
||||||
synchronized (psLock) {
|
synchronized (psLock) {
|
||||||
playbackService = ((PlaybackService.LocalBinder) service)
|
if(service instanceof PlaybackService.LocalBinder == false) {
|
||||||
.getService();
|
playbackService = ((PlaybackService.LocalBinder) service).getService();
|
||||||
startViewUpdaterIfNotRunning();
|
startViewUpdaterIfNotRunning();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
|
|
@ -258,8 +258,8 @@ public abstract class PlaybackController {
|
||||||
|
|
||||||
private final ServiceConnection mConnection = new ServiceConnection() {
|
private final ServiceConnection mConnection = new ServiceConnection() {
|
||||||
public void onServiceConnected(ComponentName className, IBinder service) {
|
public void onServiceConnected(ComponentName className, IBinder service) {
|
||||||
playbackService = ((PlaybackService.LocalBinder) service)
|
if(service instanceof PlaybackService.LocalBinder) {
|
||||||
.getService();
|
playbackService = ((PlaybackService.LocalBinder) service).getService();
|
||||||
if (!released) {
|
if (!released) {
|
||||||
queryService();
|
queryService();
|
||||||
Log.d(TAG, "Connection to Service established");
|
Log.d(TAG, "Connection to Service established");
|
||||||
|
@ -268,6 +268,7 @@ public abstract class PlaybackController {
|
||||||
"but controller has already been released");
|
"but controller has already been released");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
|
Loading…
Reference in New Issue