Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9092169
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T22:46:38+00:00 2026-06-16T22:46:38+00:00

I’m having some issues while capturing photos. Until now, I could take pictures from

  • 0

I’m having some issues while capturing photos.

Until now, I could take pictures from camera, from emulator and from a real device, without problems. But those pictures, were saved on a default route.

I wanted to edit that route, so I could set my own.

I did it this way:

File folder = new File(Environment.getExternalStorageDirectory().toString()+"/ImagesFolder/");
            folder.mkdirs();

            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            Uri uriSavedImage=Uri.fromFile(new File(Environment.getExternalStorageDirectory().toString()+"/ImagesFolder/imatge.jpg"));
            cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);

            startActivityForResult(cameraIntent, 1888);

This is working on a real device, a Sony Ericsson Xperia Ray. It creates the folder, and saves the image there.

But the issue is on emulator. I’m afraid this will happen on other devices.

This is the logcat:

01-06 21:35:21.115: E/AndroidRuntime(1565): FATAL EXCEPTION: main
01-06 21:35:21.115: E/AndroidRuntime(1565): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=264032, result=-1, data=null} to activity {com.exercise.AndroidViewPager/com.exercise.AndroidViewPager.AndroidViewPagerActivity}: java.lang.NullPointerException
01-06 21:35:21.115: E/AndroidRuntime(1565):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3319)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3362)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at android.app.ActivityThread.access$1100(ActivityThread.java:141)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at android.os.Handler.dispatchMessage(Handler.java:99)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at android.os.Looper.loop(Looper.java:137)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at android.app.ActivityThread.main(ActivityThread.java:5039)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at java.lang.reflect.Method.invokeNative(Native Method)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at java.lang.reflect.Method.invoke(Method.java:511)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at dalvik.system.NativeStart.main(Native Method)
01-06 21:35:21.115: E/AndroidRuntime(1565): Caused by: java.lang.NullPointerException
01-06 21:35:21.115: E/AndroidRuntime(1565):     at com.exercise.AndroidViewPager.MyFragmentD.onActivityResult(MyFragmentD.java:52)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at android.support.v4.app.FragmentActivity.onActivityResult(FragmentActivity.java:152)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at android.app.Activity.dispatchActivityResult(Activity.java:5293)
01-06 21:35:21.115: E/AndroidRuntime(1565):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3315)
01-06 21:35:21.115: E/AndroidRuntime(1565):     ... 11 more

The crash:

01-06 21:35:21.115: E/AndroidRuntime(1565): Caused by: java.lang.NullPointerException
01-06 21:35:21.115: E/AndroidRuntime(1565):     at com.exercise.AndroidViewPager.MyFragmentD.onActivityResult(MyFragmentD.java:52)

Comes from here:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if( requestCode == 1888 && resultCode == -1) { //-1 = TOT HA ANAT BE.
        Bitmap photo = (Bitmap) data.getExtras().get("data");
        Log.d("debugging",""+photo.getHeight());
        Log.d("debugging",""+photo.getWidth());
        ((ImageView) myFragmentView.findViewById(R.id.fotoCapturada)).setImageBitmap(photo);
    }
}

Exactly:

Bitmap photo = (Bitmap) data.getExtras().get("data");

After some research, I found out nothing clear…

Can you help me on this issue?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T22:46:39+00:00Added an answer on June 16, 2026 at 10:46 pm

    Since your data extras method isn’t working, you could try storing a field of the file or the path when the Intent is launched.

    File resultingFile;//This will be in your class definition
    
    File folder = new File(Environment.getExternalStorageDirectory().toString()+"/ImagesFolder/");
    folder.mkdirs();
    
    Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    resultingFile = new File(folder.toString() + "/image.jpg");
    Uri uriSavedImage=Uri.fromFile(resultingFile);
    cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage);
    
    startActivityForResult(cameraIntent, 1888);
    

    So when you enter onActivityResult you can test the resultCode against RESULT_OK and RESULT_CANCELED. When I use onActivityResult, I do it like this:

    if(requestCode == 1888){
      if(resultCode == RESULT_OK){ //Called when the user saves the image
         if(resultingFile.exists(){
           Bitmap photo = BitmapFactory.decodeFile(resultingFile.getPath()); 
           ((ImageView) myFragmentView.findViewById(R.id.fotoCapturada)).setImageBitmap(photo);
         }
      }else if(resultCode == RESULT_CANCELED){ //Called when the user presses back or cancels the saving of the image
    
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I'm interested in microtypography issues on the web. I want a tool to fix:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
This could be a duplicate question, but I have no idea what search terms
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.