Skip to content
Snippets Groups Projects
Commit 73845dd1 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Prevent crash on Oreo when app is in background

parent e2aa54c7
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment