From 5671636cae87506732dbcde7a7455d7ffa42b5c4 Mon Sep 17 00:00:00 2001 From: David Luhmer Date: Fri, 1 Nov 2019 12:53:23 +0100 Subject: [PATCH] fix bug that app crashed when feature is not available --- .../owncloudnewsreader/PiPVideoPlaybackActivity.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PiPVideoPlaybackActivity.java b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PiPVideoPlaybackActivity.java index 848eb0f3..6cf2ea2e 100644 --- a/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PiPVideoPlaybackActivity.java +++ b/News-Android-App/src/main/java/de/luhmer/owncloudnewsreader/PiPVideoPlaybackActivity.java @@ -1,7 +1,9 @@ package de.luhmer.owncloudnewsreader; +import android.app.AppOpsManager; import android.app.PictureInPictureParams; import android.content.ComponentName; +import android.content.Context; import android.content.pm.PackageManager; import android.content.res.Configuration; import android.graphics.Point; @@ -49,7 +51,7 @@ public class PiPVideoPlaybackActivity extends AppCompatActivity { setContentView(R.layout.activity_pip_video_playback); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N && getPackageManager().hasSystemFeature(PackageManager.FEATURE_PICTURE_IN_PICTURE)) { //moveTaskToBack(false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { PictureInPictureParams.Builder pictureInPictureParamsBuilder = new PictureInPictureParams.Builder(); @@ -59,9 +61,6 @@ public class PiPVideoPlaybackActivity extends AppCompatActivity { } else { enterPictureInPictureMode(); } - - - enterPictureInPictureMode(); } else { Toast.makeText(this, "This device does not support video playback.", Toast.LENGTH_LONG).show(); finish();