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