raghav chopra
raghav chopra

Reputation: 837

How to enable Network Location provider automatically

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);

Upvotes: 5

Views: 11982

Answers (2)

Guna
Guna

Reputation: 121

Not possible to enable it automatically. Network settings must be enabled manually by user only. You can show a message to the user to enable his network.

You can able to open the Location Services page to enable it. By programmatic, not possible.

Upvotes: 2

Antrromet
Antrromet

Reputation: 15414

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.

Upvotes: 4

Related Questions