I'm writing an app for Android 1.5. This app has the following functions in an activity called PicVid. The issue is that I need to know the uri of the video that is created and I can't figure out how to get that.
During execution (once i click the button the videoListener is waiting for) I get
I'm completely lost as to why this is happening. Any help would be appreciated.
Ps. If it helps it fails on the "String uri = b.getString("data");" line
Pss. also I've tried the commented out sections of code as well and they don't work either.
Code:
private OnClickListener videoListener = new OnClickListener() {
public void onClick(View v) {
Intent i = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
//i.putExtra(MediaStore.EXTRA_MEDIA_TITLE, "TestName");
i.putExtra(MediaStore.EXTRA_OUTPUT, MediaStore.Video.Media.EXTERNAL_CONTENT_URI.toString());
try{
startActivityForResult(i, ACTIVITY_GET_VIDEO);
}
catch(Exception ex){
Log.v("BRE", ex.toString());
}
}
};
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == ACTIVITY_GET_VIDEO) {
if (resultCode == RESULT_OK) {
Bundle b = data.getExtras();
String uri = b.getString("data");
//String uri = b.get("data");
mVideoButton.setImageResource(R.drawable.search_128);
}
}
}
Code:
05-27 12:57:18.441: ERROR/AndroidRuntime(1374): Uncaught handler: thread main exiting due to uncaught exception
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): java.lang.RuntimeException: Unable to resume activity {mobile/mobile.Info}: java.lang.RuntimeException: Failure delivering result ResultInfo{who=picvid, request=2, result=-1, data=Intent { data=content://media/external/video/media/8 }} to activity {mobile/mobile.Info}: java.lang.NullPointerException
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2632)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2647)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2287)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3278)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.app.ActivityThread.access$1900(ActivityThread.java:112)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.os.Handler.dispatchMessage(Handler.java:99)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.os.Looper.loop(Looper.java:123)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.app.ActivityThread.main(ActivityThread.java:3948)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at java.lang.reflect.Method.invokeNative(Native Method)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at java.lang.reflect.Method.invoke(Method.java:521)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at dalvik.system.NativeStart.main(Native Method)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): Caused by: java.lang.RuntimeException: Failure delivering result ResultInfo{who=picvid, request=2, result=-1, data=Intent { data=content://media/external/video/media/8 }} to activity {mobile/mobile.Info}: java.lang.NullPointerException
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.app.ActivityThread.deliverResults(ActivityThread.java:3005)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2616)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): ... 13 more
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): Caused by: java.lang.NullPointerException
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at mobile.PicVid.onActivityResult(PicVid.java:131)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.app.ActivityGroup.dispatchActivityResult(ActivityGroup.java:119)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): at android.app.ActivityThread.deliverResults(ActivityThread.java:3001)
05-27 12:57:18.551: ERROR/AndroidRuntime(1374): ... 14 more
Ps. If it helps it fails on the "String uri = b.getString("data");" line
Pss. also I've tried the commented out sections of code as well and they don't work either.