Don't crash if no uri is passed in the intent

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.
This commit is contained in:
Jan Schmidt 2017-05-20 17:30:08 +02:00
parent 1116ae85e2
commit 1e0b3ed778

View 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();
}