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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:59:22+00:00 2026-06-15T23:59:22+00:00

I have an android app which uses google map and has a feature to

  • 0

I have an android app which uses google map and has a feature to show the current location. I have received few comments saying that “the current location is not coming up even if the GPS is on.” I tried it with couple of devices but I could not see the issue but yesterday I faced the issue on my phone too where it was working fine earlier.

The solution that I figured out is if the current location is not coming up then turn off the wi-fi and use mobile internet for getting the current location and it started showing up. I know it seems little weird but it worked for me. Please suggest me the changes needed in my code, if I am missing something. I can’t suggest the above workaround for my app users.

locMgr = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
boolean enabled = locMgr.isProviderEnabled(LocationManager.GPS_PROVIDER);
cEnabled = getIntent().getExtras().getBoolean("cEnabled");

if (!enabled && !cEnabled) {
    AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
    alt_bld.setMessage("Would you like to activate GPS?\n(recommended- Yes)")
        .setCancelable(false)
        .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                Intent intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                startActivity(intent);
            }
        })
        .setNegativeButton("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                 dialog.cancel();
            }
        });

    AlertDialog alert = alt_bld.create();
    // Title for AlertDialog
    alert.setTitle("Activate GPS?");
    // Icon for AlertDialog
    alert.setIcon(R.drawable.location1);
    alert.show();       
}  

ImageButton clocButton = (ImageButton) findViewById(R.id.cLoc);
clocButton.setOnTouchListener(new OnTouchListener() {
    public boolean onTouch(View v, MotionEvent event) {
    getToMyLocation();
        return false;
    }
});

private void getToMyLocation() {
    mapView.invalidate();
    Criteria criteria = new Criteria();
    String provider = locMgr.getBestProvider(criteria, false);
    Location lastLoc = locMgr.getLastKnownLocation(provider);
    if(lastLoc != null) {
        GeoPoint lastPoint = new GeoPoint((int)(lastLoc.getLatitude()*1E6), (int)(lastLoc.getLongitude()*1E6));
        center = lastPoint;
        showLocation(lastPoint);
    }
    else
    {
        Toast.makeText(mContext, "Waiting for current location", Toast.LENGTH_SHORT).show();
    }

    myLocOverlay.enableMyLocation();
    myLocOverlay.runOnFirstFix(new Runnable() {
        public void run() {
            GeoPoint loc = myLocOverlay.getMyLocation();
            mapView.getController().setCenter(loc);
            center = loc;
        }
    });
}

private void showLocation(GeoPoint location) {
    if (location != null) {
        myLocOverlay.enableMyLocation();
        mapView.getController().animateTo(location);
    }
}

I have added following permissions in manifest file:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
  • 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-15T23:59:23+00:00Added an answer on June 15, 2026 at 11:59 pm

    I have used the Android Developers’ Making Your App Location-Aware tutorial before and it has worked fine for me. Have you looked through this and compared it to your own code?

    You may see something you are missing, or a better way of implementing parts of it, which may clear up these issues.

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

Sidebar

Related Questions

I have built an android app which use Google Map feature. I want my
I have an Android app which includes an activity called Help This uses a
I have an android app which has native code. The native code needs to
I have an Android app that I had working a few months ago which
I have an Android app which uses a service to continuously update a textview
I have an Android app which uses Jackson parser for JSON parsing. After I've
I have an Android app which uses a jar library generated from another Eclipse
I have created a simple app which shows a Google Map. I am testing
i have a android app which uses the SimpleCursorAdapter i have the min API
I have an Android app which uses a lot of activities. All those activities

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.