Commit deb6b640 authored by Geoffrey Métais's avatar Geoffrey Métais

Prevent crash on Oreo when app is in background

(cherry picked from commit 73845dd1)
parent 8556a048
......@@ -44,13 +44,20 @@ public class RemoteControlClientReceiver extends MediaButtonReceiver {
@Override
public void onReceive(Context context, Intent intent) {
final String action = intent.getAction();
if (action == null) return;
final KeyEvent event = intent.getParcelableExtra(Intent.EXTRA_KEY_EVENT);
if (event != null && action.equalsIgnoreCase(Intent.ACTION_MEDIA_BUTTON)) {
if (event.getKeyCode() != KeyEvent.KEYCODE_HEADSETHOOK &&
event.getKeyCode() != KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
super.onReceive(context, intent);
if (!AndroidUtil.isOOrLater || VLCApplication.isForeground()) super.onReceive(context, intent);
else if (event.getAction() == KeyEvent.ACTION_DOWN &&
event.getKeyCode() == KeyEvent.KEYCODE_MEDIA_PLAY) {
intent = new Intent(context, PlaybackService.class);
intent.setAction(Constants.ACTION_REMOTE_PLAYPAUSE);
Util.startService(context, intent);
}
return;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment