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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:07:07+00:00 2026-06-05T00:07:07+00:00

Created a Location alarm based app. Everything is working fine on emulator. But the

  • 0

Created a Location alarm based app. Everything is working fine on emulator. But the following error occurs in real device.

Scenario:

Turned on GPS.
Opened my app in phone.
No GPS symbol in status bar.
App getting force closed.

To fix this scenario, I am doing the following thing

Open any application like Maps, GPS Essentials.
My GPS values is getting fixed.
Opening my application after that.
App working fine.

Providing the necessary codes below:

in my Oncreate method

fixlocation = orgManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);


@Override
protected void onResume() {
    super.onResume();
    orgManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 1000, this);
    orgManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 1000, this);
    mo.enableCompass();
    mo.enableMyLocation();
}

/** Stop the updates when Activity is paused */
@Override
protected void onPause() {
    super.onPause();
    orgManager.removeUpdates(this);
    mo.disableCompass();
    mo.disableMyLocation();
}



@Override
    public void onLocationChanged(Location location) {
        // TODO Auto-generated method stub

        //orgManager.removeUpdates(this);

        if (location != null) {
            currLatitude = location.getLatitude();
            currLongtitude = location.getLongitude();
}}

What do I need to do now?

  • 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-05T00:07:08+00:00Added an answer on June 5, 2026 at 12:07 am
    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
    
    currLat = location.getLatitude();
    currentLang = location.getLongitude();
    

    Try this to get current location.

    onLocationChanged will call only when location of your device changes but

    first time when your application starts you can use this code.

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

Sidebar

Related Questions

I created this earlier on today, but it is not working. Location manager returns
I just created a module location.rb inside /lib folder with following contents: module Location
I created following shortcode function to call a menu on a specific location on
i created application for showing location and latitude,longitude for where am i? but gps
I have a wordpress blog hosted on IIS. Everything was working fine until I
We created a small app, that tells your location. On some devices, if there
I am making an app that allows the user to set an alarm based
I am trying to implement a location alarm kind of application. But whenever my
How to prefill title and location for created event in EKEventEditViewController? Should I create
I created a query that takes a database backup at certain specified location. I

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.