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

  • Home
  • SEARCH
  • 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 3795610
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:06:36+00:00 2026-05-19T13:06:36+00:00

I am using this tutorial / code to learn the camera functions: cam tutorial.

  • 0

I am using this tutorial / code to learn the camera functions: cam tutorial.

The app is crashing after the camera Intent takes the picture and returns to onActivityResult. But I am checking the make sure data is not null:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
System.out.println("***** inside onActivityResult");

  if (requestCode == TAKE_PICTURE) {
    if (data != null) {
    System.out.println("***** inside data !=null if");

      imageid = data.getData().getLastPathSegment(); //returns full pic id
      System.out.println("***** imageid:" + imageid);
[...]

I get inside the data != null if statement and it crashes when I imageid = data.getData().getLastPathSegment();.

Logcat:

01-20 12:45:02.678: ERROR/AndroidRuntime(1626): FATAL EXCEPTION: main
01-20 12:45:02.678: ERROR/AndroidRuntime(1626): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { act=inline-data (has extras) }} to activity {org.kimile/org.kimile.Camera}: java.lang.NullPointerException
01-20 12:45:02.678: ERROR/AndroidRuntime(1626): at android.app.ActivityThread.deliverResults(ActivityThread.java:3515)
01-20 12:45:02.678: ERROR/AndroidRuntime(1626): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3557)
01-20 12:45:02.678: ERROR/AndroidRuntime(1626): at android.app.ActivityThread.access$2800(ActivityThread.java:125)
01-20 12:45:02.678: ERROR/AndroidRuntime(1626): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)

I can’t figure out why its throwing the null exception even know I am checking to make sure its not null.

  • 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-05-19T13:06:37+00:00Added an answer on May 19, 2026 at 1:06 pm

    Your code is throwing a NullPointerException because the object returned from data.getData() is null. Thus when you call getData().getLastPathSegment(), the method getLastPathSegment() is being called on a null object – giving you your NPE.

    Like willytate said, if you want to avoid the problem all together make sure you check the value of resultCode. Otherwise, make sure you check if getData() is null as well.

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

Sidebar

Related Questions

I got this code below from a tutorial I'm using to learn PHP. I
I'm using this code: UIAlertView *alert = [[UIAlertView alloc] init]; [alert setTitle:@Select Tutorial]; [alert
I'm using this code, to make a request to a given URL: private static
I'm referencing the jQuery autocomplete plugin code seen in this tutorial: http://net.tutsplus.com/tutorials/javascript-ajax/how-to-use-the-jquery-ui-autocomplete-widget/ The problem
i am using this tutorial to make android as a Rest client . The
I'm using this tutorial to build an application using the MVC architecture : http://www.oracle.com/technetwork/articles/javase/index-142890.html
Using this question as the base is there an alogrithm or coding example to
Since I have started using this site, I keep hearing about the Boost library.
I've been using this nifty LINQ to SQL tool for a data access layer
anyone have any experience using this? if so, is it worth while?

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.