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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:49:43+00:00 2026-06-11T09:49:43+00:00

I currently have a project in which the main activity launches another activity for

  • 0

I currently have a project in which the main activity launches another activity for information gathering and then goes back to the main activity. I am trying to handle the back button press. Every time I execute the following code it crashes. But I don’t understand why.

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {

        finish();
        return true;
    }
    return super.onKeyDown(keyCode, event);
};

I have also tried:

@Override
    public void onBackPressed() {
            finish();
    };

Stack trace:

09-14 15:30:13.740: E/AndroidRuntime(32400): FATAL EXCEPTION: main
09-14 15:30:13.740: E/AndroidRuntime(32400): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=2, result=0, data=null} to activity {peaBerry.Shopping.Consultant/peaBerry.Shopping.Consultant.PeaBerryTeaActivity}: java.lang.NullPointerException
09-14 15:30:13.740: E/AndroidRuntime(32400):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2655)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at android.app.ActivityThread.handleSendResult(ActivityThread.java:2697)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at android.app.ActivityThread.access$2000(ActivityThread.java:124)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:998)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at android.os.Handler.dispatchMessage(Handler.java:99)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at android.os.Looper.loop(Looper.java:130)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at android.app.ActivityThread.main(ActivityThread.java:3806)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at java.lang.reflect.Method.invokeNative(Native Method)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at java.lang.reflect.Method.invoke(Method.java:507)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at dalvik.system.NativeStart.main(Native Method)
09-14 15:30:13.740: E/AndroidRuntime(32400): Caused by: java.lang.NullPointerException
09-14 15:30:13.740: E/AndroidRuntime(32400):    at peaBerry.Shopping.Consultant.PeaBerryTeaActivity.onActivityResult(PeaBerryTeaActivity.java:312)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at android.app.Activity.dispatchActivityResult(Activity.java:3958)
09-14 15:30:13.740: E/AndroidRuntime(32400):    at android.app.ActivityThread.deliverResults(ActivityThread.java:2651)
  • 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-11T09:49:45+00:00Added an answer on June 11, 2026 at 9:49 am

    According to the error message, a result is missing. Have you started the 2nd Activity with startActivityForResult()? If so, add a setResult(value) or setResult(value, data) before calling finish() in your 2nd Activity, to pass back the expected result to the calling Activity.

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

Sidebar

Related Questions

Currently, I have a Maven project which inherits from a parent pom defining two
I have to reuse a major C++ project which is currently developed inside eclipse,
I am currently doing a project in which I have to request data from
I have a project which uses Apache Xmlbeans for databinding. Currently it is very
I am currently working on a project which supports multi-language. I have created a
In the main class of my project, I have public class MyClass extends Activity{
I have an Android test project in which I test my main application. The
We currently have a Database Project, which we wrote a WIX Installer for to
I have a project which builds correctly from the command line. On one of
I have a GWT project in which I need to manually specify currency, number

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.