For below codes, as you can see, one new Intent is in bindService(), and another new Intent occurs in startService(). And I just wonder if there will be two Intents finally? Or the two Intents are still OK?
bindService(new Intent(this, MusicPlayerService.class),
mPlaybackConnection, Context.BIND_AUTO_CREATE);
startService(new Intent(this, MusicPlayerService.class));
This code is equivalent to:
In the code you provided, an identical
Intentobject is created each time.The code is equivalent in the sense that they both do the same thing. However, using one Intent throughout would be very very slightly faster, as the object is only created once. Other than that, both are correct, and both do the same thing.