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 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 a tutorial plugin - http://particlebits.com/code/jquery-tutorial/ which has this code attached to the
I'm following the barcode tutorial for this site: http://brismith66.blogspot.com/2010_07_01_archive.html using the google code: http://code.google.com/p/wsdl2objc/
everyone. This is a piece of code from using sqlite in android tutorial: return
Given the code block below (source: http://www.asp.net/learn/mvc/tutorial-31-cs.aspx )... I receive this error: Using the
I have recently started a tutorial to learn how to code GUI using Windows
I'm trying to learn wxWidgets using this tutorial . It directs me to use
Hi I start learn Fluent NHibernate. I am using this tutorial http://www.d80.co.uk/post/2011/02/20/Linq-to-NHibernate-Tutorial.aspx . Here
I'm using this tutorial to learn some basic d3 . I'm at the binding
I am using this code to send mail with php http://www.siteduzero.com/tutoriel-3-35146-e-mail-envoyer-un-e-mail-en-php.html#ss_part_4 . This code

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.