Video Capture issues


Last Updated:

  1. j_p36

    j_p36 Member This Topic's Starter

    Joined:
    May 19, 2010
    Messages:
    16
    Likes Received:
    0
    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.

    Code (Text):
    1. private OnClickListener videoListener = new OnClickListener() {
    2.         public void onClick(View v) {
    3.             Intent i = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    4.  
    5.             //i.putExtra(MediaStore.EXTRA_MEDIA_TITLE, "TestName");
    6.             i.putExtra(MediaStore.EXTRA_OUTPUT, MediaStore.Video.Media.EXTERNAL_CONTENT_URI.toString());
    7.            
    8.             try{
    9.                 startActivityForResult(i, ACTIVITY_GET_VIDEO);
    10.             }
    11.             catch(Exception ex){
    12.                 Log.v("BRE", ex.toString());
    13.             }
    14.         }
    15.     };
    16.  
    17.     protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    18.         if (requestCode == ACTIVITY_GET_VIDEO) {
    19.  
    20.             if (resultCode == RESULT_OK) {
    21.                 Bundle b = data.getExtras();
    22.                 String uri = b.getString("data");
    23.               //String uri = b.get("data");
    24.                
    25.                 mVideoButton.setImageResource(R.drawable.search_128);
    26.             }
    27.         }
    28.     }
    During execution (once i click the button the videoListener is waiting for) I get

    Code (Text):
    1. 05-27 12:57:18.441: ERROR/AndroidRuntime(1374): Uncaught handler: thread main exiting due to uncaught exception
    2. 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
    3. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2632)
    4. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2647)
    5. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2287)
    6. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:3278)
    7. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.app.ActivityThread.access$1900(ActivityThread.java:112)
    8. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
    9. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.os.Handler.dispatchMessage(Handler.java:99)
    10. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.os.Looper.loop(Looper.java:123)
    11. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.app.ActivityThread.main(ActivityThread.java:3948)
    12. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at java.lang.reflect.Method.invokeNative(Native Method)
    13. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at java.lang.reflect.Method.invoke(Method.java:521)
    14. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
    15. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
    16. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at dalvik.system.NativeStart.main(Native Method)
    17. 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
    18. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3005)
    19. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.app.ActivityThread.performResumeActivity(ActivityThread.java:2616)
    20. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     ... 13 more
    21. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374): Caused by: java.lang.NullPointerException
    22. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at mobile.PicVid.onActivityResult(PicVid.java:131)
    23. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.app.ActivityGroup.dispatchActivityResult(ActivityGroup.java:119)
    24. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3001)
    25. 05-27 12:57:18.551: ERROR/AndroidRuntime(1374):     ... 14 more
    26.  
    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.
     

    Advertisement
  2. Boogs

    Boogs Well-Known Member

    Joined:
    Apr 6, 2010
    Messages:
    85
    Likes Received:
    16
    From your error code, it appears that "b" is set to null. Which would mean that there are no extras in your "data" Intent. To confirm this, put it in debug mode and break the execution at:
    Code (Text):
    1. Bundle b = data.getExtras();
    Step to the next line and confirm whether or not "b" is null. If that is the case, the most likely culprit is in the activity which is returning the bundle; probably something not there, like:
    Code (Text):
    1. intent.putExtras(new Bundle());
     
    j_p36 likes this.
  3. j_p36

    j_p36 Member This Topic's Starter

    Joined:
    May 19, 2010
    Messages:
    16
    Likes Received:
    0
    Wow, thanks alot. I was using someone else's code and I copied the Bundle "b = data.getExtras". b was null. the problem was I needed to do "data.getData();" to get it instead. I never have been good at following stack trace errors.
     

Share This Page

Loading...