Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enable Network Location provider automatically

Tags:

android

I am fetching Latitude and Longitude through network

It is giving me latitude and longitude but what if my NETWORK LOCATION PROVIDER is unchecked

It will never provide me the Latitude and Longitude of the current location.

What i want is, How Can I enable the NETWORK LOCATION PROVIDER in phone without knowing user that It is opened,

How can i do that?

What i have tried is:

Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivityForResult(intent, 1);

But this will open the page in my phone to check it  i want to check AUTOMATICALLY          

Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName("com.android.phone", "com.android.phone.Settings");
startActivity(intent);
like image 995
raghav chopra Avatar asked Oct 31 '12 12:10

raghav chopra


People also ask

How do I turn location on automatically?

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.

What is network location provider?

A source for obtaining the location of a mobile device. Satellite-based GPS is the major location provider. Assisted GPS (A-GPS) uses the cellular system, which knows where a phone is at all times, and cellular base stations report their cell location number (CELL ID) to pinpoint a device.

How can enable location permission in Android programmatically?

Programmatically we can turn on GPS in two ways. First, redirect the user to location settings of a device (by code) or another way is to ask to turn on GPS by GPS dialog using LocationSettingsRequest and SettingsClient.


1 Answers

It is impossible to enable the network provider location automatically as already mentioned. The correct way is to display a box and redirect the user to the settings page. You can enable GPS by using a slight hack as mentioned here. Still I wouldn't suggest doing that.

like image 83
Antrromet Avatar answered Sep 23 '22 05:09

Antrromet