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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:05:22+00:00 2026-06-17T20:05:22+00:00

I am developing an app that displays a mapview, and overlays an image that

  • 0

I am developing an app that displays a mapview, and overlays an image that I download from the internet.

The app waits for the user to press a button, and then centers the map on the user’s current location.

Everything was working fine at one point. But I think things got messed up when I updated my test phone ( Galaxy SIII ) to Jelly Bean.

The app crashes when I press the button to get the current GPS position, center the map, and overlay the image.

Below is the output from LogCat. I am unsure what any of it means, so if you could help me make sense of it I would really appreciate it!

Excerpt from my code that I think is the issue:

The Button listener:

mUpdateButton.setOnClickListener(new View.OnClickListener() 
    {
        public void onClick(View arg0) 
        {
            // Start listening for location
            myLocationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0,myLocationListener);

            // Get Lat and Long coordinates, and format them
            MyLat = (int)(myLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLatitude()*1000000);
            MyLong = (int)(myLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLongitude()*1000000);

            // Save the Lat and Long into a GeoPoint
            GeoPoint initGeoPoint = new GeoPoint(MyLat,MyLong);

            // Center location on current pos
            CenterLocatio(initGeoPoint, 10);

            // Stop listening for location
            myLocationManager.removeUpdates(myLocationListener);
        }
    });

The CenterLocatio function:

private void CenterLocatio(GeoPoint centerGeoPoint, int zoomLevel)
{
    myMapController.animateTo(centerGeoPoint);
    myMapController.setZoom(zoomLevel);

    myLongitude.setText("Longitude: "+
            String.valueOf((float)centerGeoPoint.getLongitudeE6()/1000000)
            );
    myLatitude.setText("Latitude: "+
            String.valueOf((float)centerGeoPoint.getLatitudeE6()/1000000)
            );



    // Get location of the storage location
    File extStore = Environment.getExternalStorageDirectory();
    String PATH = extStore + "/data/tntechpie/";
    // Add new overlay to Map
    List<Overlay> mapOverlays = myMapView.getOverlays();
    // Set drawable to the downloaded image from the storage location
    //Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);

    @SuppressWarnings("deprecation")
    Drawable drawable = new BitmapDrawable(PATH + "testMap.gif");
    myItemizedOverlay itemizedoverlay = new myItemizedOverlay(drawable, this);

    OverlayItem overlayitem = new OverlayItem(centerGeoPoint, "", "");
    itemizedoverlay.addOverlay(overlayitem);
    mapOverlays.add(itemizedoverlay);
};

The LogCat Output:

01-22 12:34:31.062: I/MapActivity(6919): Handling network change notification:CONNECTED
01-22 12:34:31.062: E/MapActivity(6919): Couldn't get connection factory client
01-22 12:34:33.465: D/AndroidRuntime(6919): Shutting down VM
01-22 12:34:33.465: W/dalvikvm(6919): threadid=1: thread exiting with uncaught exception (group=0x41f44438)
01-22 12:34:33.475: E/AndroidRuntime(6919): FATAL EXCEPTION: main
01-22 12:34:33.475: E/AndroidRuntime(6919): java.lang.NullPointerException
01-22 12:34:33.475: E/AndroidRuntime(6919):     at com.androidlocation.MainActivity$1.onClick(MainActivity.java:120)
01-22 12:34:33.475: E/AndroidRuntime(6919):     at android.view.View.performClick(View.java:4198)
01-22 12:34:33.475: E/AndroidRuntime(6919):     at android.view.View$PerformClick.run(View.java:17158)
01-22 12:34:33.475: E/AndroidRuntime(6919):     at android.os.Handler.handleCallback(Handler.java:615)
01-22 12:34:33.475: E/AndroidRuntime(6919):     at android.os.Handler.dispatchMessage(Handler.java:92)
01-22 12:34:33.475: E/AndroidRuntime(6919):     at android.os.Looper.loop(Looper.java:137)
01-22 12:34:33.475: E/AndroidRuntime(6919):     at android.app.ActivityThread.main(ActivityThread.java:4918)
01-22 12:34:33.475: E/AndroidRuntime(6919):     at java.lang.reflect.Method.invokeNative(Native Method)
01-22 12:34:33.475: E/AndroidRuntime(6919):     at java.lang.reflect.Method.invoke(Method.java:511)
01-22 12:34:33.475: E/AndroidRuntime(6919):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
01-22 12:34:33.475: E/AndroidRuntime(6919):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
01-22 12:34:33.475: E/AndroidRuntime(6919):     at dalvik.system.NativeStart.main(Native Method)
01-22 12:34:41.924: I/Process(6919): Sending signal. PID: 6919 SIG: 9
  • 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-17T20:05:23+00:00Added an answer on June 17, 2026 at 8:05 pm
    java.lang.NullPointerException 
        at com.androidlocation.MainActivity$1.onClick(MainActivity.java:120) 
    

    This error means that on line 120, you are asking a variable that equal nothing (ie null) to do something. The problem probably happens here in your onClick() method:

    MyLat = (int)(myLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLatitude()*1000000);
    MyLong = (int)(myLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLongitude()*1000000);
    

    But getLastKnownLocation() may return null if there is no recent fix available. You should check to see if this returns a usable value before trying to read from it.

    Location lastknown = myLocationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    if(lastKnown != null) {
        // Read the lat / long data
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm developing an app that has a jtable and user could start a download.
I'm developing an app that displays users' tweets along with their image. But the
I'm developing an app that displays location on a map when I press the
I am developing a simple Mobile App that displays currency rates from an XML
I am developing an iPhone app that displays several views, all acessed via Tab
I'm developing an iPhone app that switches from a table view to a landscape
I am developing an app that displays content that is also displayed on a
I am developing an app for my Universities campus that displays the campus in
I am currently developing an android app that displays a list view. When an
I'm developing an app that, for a given location (coordinate lat/long pair), it displays

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.