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 8801957
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:57:55+00:00 2026-06-14T00:57:55+00:00

I am using camera Intent to open the camera: Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

  • 0

I am using camera Intent to open the camera:

Intent cameraIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraIntent, CAMERA_REQUEST);

Now I am trying to get the path of the captured photo but its throwing error:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CAMERA_REQUEST) {
Uri uri = data.getData();
String imagePath = getRealPathFromURI(uri);
}
}

private String getRealPathFromURI(Uri contentUri) {
    String[] proj = { MediaStore.Images.Media.DATA };
// import android.support.v4.content.CursorLoader; i import this for CursorLoader
    CursorLoader loader = new CursorLoader(getApplicationContext(), contentUri, proj, null, null, null);
    Cursor cursor = loader.loadInBackground();
    int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
    cursor.moveToFirst();
    return cursor.getString(column_index);
}

Its throwing Error which is:

FATAL EXCEPTION: main
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=100,     result=-1, data=Intent { act=inline-data (has extras) }} to activity  {com.xxx.xxx.BbmpActivity}: java.lang.NullPointerException

at android.app.ActivityThread.deliverResults(ActivityThread.java:2536)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:2578)
at android.app.ActivityThread.access$2000(ActivityThread.java:117)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:965)
at android.os.Handler.dispatchMessage(Handler.java:99)  
at android.os.Looper.loop(Looper.java:130)
at android.app.ActivityThread.main(ActivityThread.java:3687)    
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:507)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)     
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException   
at android.content.ContentResolver.acquireProvider(ContentResolver.java:743)    
at android.content.ContentResolver.query(ContentResolver.java:256)
at android.support.v4.content.CursorLoader.loadInBackground(CursorLoader.java:49)
at com.pixel.bbmp.BbmpActivity.getRealPathFromURI2(BbmpActivity.java:546)
at com.pixel.bbmp.BbmpActivity.onActivityResult(BbmpActivity.java:491)  
at android.app.Activity.dispatchActivityResult(Activity.java:3908)  
at android.app.ActivityThread.deliverResults(ActivityThread.java:2532)

I think because of this line it throwing error:

CursorLoader loader = new CursorLoader(getApplicationContext(), contentUri, proj, null, null, null);

here what i need to give instead of getApplicationContext()
I also try this but till it throwing error:

CursorLoader loader = new CursorLoader(this, contentUri, proj, null, null, null);

when I start this application then it throw one error which is:

Could not find class 'android.content.CursorLoader', referenced from method com.xxx.xxx.BbmpActivity.getRealPathFromURI
  • 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-14T00:57:57+00:00Added an answer on June 14, 2026 at 12:57 am

    Instead of Uri uri = data.getData();write like..

    if(data!=null){
      if (requestCode == CAMERA_REQUEST) {  
               Uri uri =  data.getExtras().get("data"); 
             //or...
         Bitmap bitmapPicture = (Bitmap) data.getExtras().get("data"); 
         // other code
    }
    }
    

    It will work fine. main thing is data.getExtras().get("data");

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using intent to launch camera: Intent cameraIntent = new Intent( android.provider.MediaStore.ACTION_IMAGE_CAPTURE); getParent().startActivityForResult(cameraIntent,
I am using the camera by creating an intent: Intent cameraI = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
My app is using this Intent to take photos: startActivityForResult(new Intent(MediaStore.ACTION_IMAGE_CAPTURE), TAKE_PICTURE); But the
I am opening android camera using intent like this : Intent cameraIntent = new
I am capturing images using MediaStore.ACTION_IMAGE_CAPTURE intent. it is working fine in most of
I'm trying to take a picture from the Camera using intent with onActivityResult but
Hi I'm using this to open up the native android camera application Intent camera
I am using the default camera intent to get the image in my app.
This is follow up to: Android local variable get's lost when using camera intent
I am invoking a camera using an intent and clicking a picture. Presently I

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.