I need to get location of user. I put in manifest
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
How to prompt user to enable GPS_PROVIDER and/or NETWORK_PROVIDER ?
Settings > Location > Mode > Battery Saving . This mode only uses WiFi, Bluetooth or mobile data instead of GPS to determine the user location. That's why you have to check if the network provider is enabled and locationManager.
The, after opening the Trip Advisor app, and tapping the Near me now option, I'm prompted with the second image, where I'm asked to Turn on Location services. After I tap the button, a dialog shows up so I can allow, or disallow, the Location service to be turned on.
Open your phone's Settings app. Under "Personal," tap Location access. At the top of the screen, turn Access to my location on or off.
You can start an options intent for the location settings.
Intent gpsOptionsIntent = new Intent( android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(gpsOptionsIntent);
LOCATION_MODE will be LOCATION_MODE_OFF if GPS is off, which will return value 0.
int off = Settings.Secure.getInt(getContentResolver(), Settings.Secure.LOCATION_MODE); if(off==0){ Intent onGPS = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(onGPS); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With