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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:44:19+00:00 2026-05-29T20:44:19+00:00

I am working on the application to find the user location . In my

  • 0

I am working on the application to find the user location .
In my mapview I complete the task perfect.
but while finding the location I didn’t get it.
below is my code and logcat error too..

Code:

    tv = (TextView)findViewById(R.id.tv1);

    mlocationManager =(LocationManager)getSystemService(LOCATION_SERVICE) ;

    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_FINE);
    criteria.setPowerRequirement(Criteria.POWER_LOW);

    String locatinProvider = mlocationManager.getBestProvider(criteria,true);

    Location mlocation = mlocationManager.getLastKnownLocation(locatinProvider);

    tv.setText("Last location lat:" +mlocation.getLatitude() + "long:" + mlocation.getLongitude() );

LogCat:

02-17 17:13:12.260: E/AndroidRuntime(1215): FATAL EXCEPTION: main
02-17 17:13:12.260: E/AndroidRuntime(1215): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.satyam.curlocation/com.satyam.curlocation.CurLocationActivity}: java.lang.NullPointerException
02-17 17:13:12.260: E/AndroidRuntime(1215):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1622)
02-17 17:13:12.260: E/AndroidRuntime(1215):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1638)
02-17 17:13:12.260: E/AndroidRuntime(1215):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
02-17 17:13:12.260: E/AndroidRuntime(1215):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:928)
02-17 17:13:12.260: E/AndroidRuntime(1215):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-17 17:13:12.260: E/AndroidRuntime(1215):     at android.os.Looper.loop(Looper.java:123)
02-17 17:13:12.260: E/AndroidRuntime(1215):     at android.app.ActivityThread.main(ActivityThread.java:3647)
02-17 17:13:12.260: E/AndroidRuntime(1215):     at java.lang.reflect.Method.invokeNative(Native Method)
02-17 17:13:12.260: E/AndroidRuntime(1215):     at java.lang.reflect.Method.invoke(Method.java:507)
02-17 17:13:12.260: E/AndroidRuntime(1215):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-17 17:13:12.260: E/AndroidRuntime(1215):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-17 17:13:12.260: E/AndroidRuntime(1215):     at dalvik.system.NativeStart.main(Native Method)
02-17 17:13:12.260: E/AndroidRuntime(1215): Caused by: java.lang.NullPointerException
  • 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-29T20:44:21+00:00Added an answer on May 29, 2026 at 8:44 pm

    getLastKnownLocation() returns null if there is no last location available or provider is disabled. See the manual.

    Location mlocation = mlocationManager.getLastKnownLocation(locatinProvider);
    
    if(mlocation != null){
        tv.setText("Last location lat:" +mlocation.getLatitude() + "long:" + mlocation.getLongitude() );
    }else{
        tv.setText("No last location available");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a android application in that i want find the user location
I am currently working in an application where I need to find all occurrences
I am trying to implement ios mapView related application,Before 3 hour my application working
I'm running CentOS 5, and am trying to get a django application working with
I am working on an app that keeps track of user's location at a
Background I'm working on an application which requires user-entered content, and I've decided to
I'm working on a very basic practice application where a user can create multiple
I'm working on an application in which a user is automatically logged in to
I'm working on a web application where I need to warn the user that
I'm trying to keep my application working even if the user doesn't have js,

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.