Don't crash if no uri is passed in the intent
authorJan Schmidt <jan@centricular.com>
Sat, 20 May 2017 15:30:08 +0000 (17:30 +0200)
committerJan Schmidt <jan@centricular.com>
Sat, 20 May 2017 15:30:08 +0000 (17:30 +0200)
If we receive an intent with no attached data, don't
throw a null pointer exception - just don't set a URI
on the player.

playback/player/android/app/src/main/java/org/freedesktop/gstreamer/player/Play.java

index f1cb0cc..ec6e5cf 100644 (file)
@@ -133,15 +133,17 @@ public class Play extends Activity implements SurfaceHolder.Callback, OnSeekBarC
         Intent intent = getIntent();
         android.net.Uri uri = intent.getData();
         Log.i ("GStreamer", "Received URI: " + uri);
-        if (uri.getScheme().equals("content")) {
-            android.database.Cursor cursor = getContentResolver().query(uri, null, null, null, null);
-            cursor.moveToFirst();
-            mediaUri = "file://" + cursor.getString(cursor.getColumnIndex(android.provider.MediaStore.Video.Media.DATA));
-            cursor.close();
-        } else {
-            mediaUri = uri.toString();
+        if (uri != null) {
+            if (uri.getScheme().equals("content")) {
+                android.database.Cursor cursor = getContentResolver().query(uri, null, null, null, null);
+                cursor.moveToFirst();
+                mediaUri = "file://" + cursor.getString(cursor.getColumnIndex(android.provider.MediaStore.Video.Media.DATA));
+                cursor.close();
+            } else {
+                mediaUri = uri.toString();
+            }
+            player.setUri(mediaUri);
         }
-        player.setUri(mediaUri);
 
         updateTimeWidget();
     }