2017-12-25 4 views
0

Dies ist unser Code für Video Picker, ziemlich Standard-Code. Dieser Code funktioniert in der Android-Version vor Nougat, löst jedoch eine Ausnahme im Nougat aus.Video Picker - Ausnahme in Nougat

private void pickVideoFromGallery(Activity activity){ 
    Intent intent = new Intent(Intent.ACTION_PICK, 
      android.provider.MediaStore.Video.Media.EXTERNAL_CONTENT_URI); 
    intent.setType("video/*"); 
    intent.addCategory(Intent.CATEGORY_OPENABLE); 
    activity.startActivityForResult(intent, MediaPicker.TYPE_FILEVIDEO); 
} 

Und die Ausnahme ist

android.content.ActivityNotFoundException: No Activity found to handle 
Intent { act=android.intent.action.PICK cat=[android.intent.category.OPENABLE] 
typ=video/* launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } } 

Allerdings, wenn ich folgende Zeile auskommentieren, es beginnt zu arbeiten, aber das ist nicht die Lösung, da wir nur geöffnet werden kann, Video

intent.addCategory(Intent.CATEGORY_OPENABLE); 

Alle auswählen suchen Idee?

+0

Bitte beenden Sie die Android-Tag auf Ihre Frage Titel hinzufügen. –

Antwort

0

Starten Sie die Standard-Dateiauswahl mit Videos.

Intent intent = new Intent(); 
intent.setType("video/*"); 
intent.setAction(Intent.ACTION_GET_CONTENT); 
startActivityForResult(intent, 1); 
0
 Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT); 
     galleryIntent.addCategory(Intent.CATEGORY_OPENABLE); 
     galleryIntent.setType("video/*"); 
     Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); 
     chooserIntent.putExtra(Intent.EXTRA_INTENT, galleryIntent); 
     chooserIntent.putExtra(Intent.EXTRA_TITLE, "File Chooser"); 
Verwandte Themen