2

I am trying to pick video file through intent and extract meta data from the video.

However, I got some error reports from users and reporting following exception:

Exception java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=12004, result=-1, data=Intent { dat=content://media/external/images/media/63141 flg=0x1 (has extras) }} to activity {my.app/my.app.VideoActivity}: 
java.lang.RuntimeException: setDataSource failed: status = 0x80000000

Here is the code grabbing meta data:

protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    Uri uri = intent.getData();
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    try {
        retriever.setDataSource(this, uri); // error occurs here
    } catch (IllegalArgumentException e) {
        e.printStackTrace();           
    } catch (SecurityException e) {
        e.printStackTrace();           
    }
}

Why does the exception appears and how to fix it?

Season
  • 1,178
  • 2
  • 22
  • 42

1 Answers1

0

One issue with this method in more recent API versions is that it requires manifest permissions and this is not always obvious form the error message - see this discussion: https://code.google.com/p/android/issues/detail?id=35794

If this is the issue then for your case I think your URI looks like it is to a local file so you would want file read/write permission. If it was an internet URL then you would want internet permission.

Mick
  • 24,231
  • 1
  • 54
  • 120