After following a tutorial on SO I found a way to get GPS to enable after a person goes into my app. The issue being is that I have the code set up to change the display for lat and lon to change as the user changes position. I know it works because I have my first GPS running smooth. Right now I am trying to implement it on my existing code.
Aside the point when I run the code the GPS Icon flashes like it working but when I go into the app nothing changes.
Here is the code I was using:
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
sendBroadcast(intent);
Any tips on getting this to fully function please do tell!
A better solution to your problem is to ask user to enable GPS himself. Doing it without user’s permission can be pretty harmful, imagine that a device’s battery is almost empty and enabling GPS will kill the battery right away. To ask user to enable GPS you can fire an
AlertDialog, create anIntentwith theACTION_LOCATION_SOURCE_SETTINGSto open the device’s Settings menu, where the user will be able to enable GPS. Hope this helps.