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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T03:33:40+00:00 2026-05-31T03:33:40+00:00

I am working on a program and i am using an intent in a

  • 0

I am working on a program and i am using an intent in a button to switch between activities.

It keeps crashing my app (it gives me the unable to resume activity,java.lang.nullPointer Exception error) and i cant seem to figure out why my code is below.

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final Button button1 = (Button) findViewById(R.id.button1);
    button1.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Perform action on click
            Intent i= new Intent(Main.this,LocationMonitor.class);
            startActivity(i);
        }
    });

    final Button button2 = (Button) findViewById(R.id.button2);
    button2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Perform action on click
            finish();
        }
    });
}

Below is the activity being launched:

public class LocationMonitor extends Activity implements LocationListener {
    private static final String TAG = "LocationDemo";
    private static final String[] S = { "Out of Service",
        "Temporarily Unavailable", "Available" };

    private TextView output;
    private LocationManager locationManager;
    private String bestProvider;
    private double myLat;
    private double myLong;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.locationlayout);


            output.append("\n\n" + location.toString());
    }

}

Error Log Post:

  03-11 22:28:42.785: E/AndroidRuntime(6817): Uncaught handler: thread main exiting due to uncaught exception
  03-11 22:28:42.796: E/AndroidRuntime(6817): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.POG_version1/com.android.POG_version1.LocationMonitor}: java.lang.NullPointerException
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at android.app.ActivityThread.access$2200(ActivityThread.java:119)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at android.os.Handler.dispatchMessage(Handler.java:99)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at android.os.Looper.loop(Looper.java:123)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at android.app.ActivityThread.main(ActivityThread.java:4363)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at java.lang.reflect.Method.invokeNative(Native Method)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at java.lang.reflect.Method.invoke(Method.java:521)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at dalvik.system.NativeStart.main(Native Method)
  03-11 22:28:42.796: E/AndroidRuntime(6817): Caused by: java.lang.NullPointerException
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at com.android.POG_version1.LocationMonitor.onCreate(LocationMonitor.java:60)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  03-11 22:28:42.796: E/AndroidRuntime(6817):   at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
  • 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-31T03:33:41+00:00Added an answer on May 31, 2026 at 3:33 am

    Make sure you are correctly initializing locationManager when you first start your Activity. Your implementation is throwing a NullPointerException when you try to make the call locationManager.requestLocationUpdates().

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

Sidebar

Related Questions

i'm working with a multi-threaded program (using pthreads) that currently create a background thread
I am working on a large number adding program (without using biginteger class). I
I'm working on a picture select/crop program and using this code below: http://www.androidworks.com/crop_large_photos_with_android/comment-page-1#comment-969 As
I am working on a program in C and using the SDCC compiler for
I'm working on a program that accesses StarTeam using the StarTeam SDK for .NET.
I was working on a program in Netbeans on Linux using a gcc compiler
I am working on a program base on C++ and also using SiliconSoftware interface.
I'm working on a program for my C++ programming class, using wxWidgets. I'm having
I am using Junit 4. My whole program is working fine. I am trying
We're working on a C program compiled with arm-eabi-gcc under Linux. We're using a

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.