5

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);
Ranjit
  • 5,130
  • 3
  • 30
  • 66
raghav chopra
  • 827
  • 3
  • 9
  • 25
  • Both answers are right: you cannot move system settings like that just from your application, by design and for obvious security reasons. – shkschneider Oct 31 '12 at 12:46

2 Answers2

4

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.

Community
  • 1
  • 1
Antrromet
  • 15,294
  • 10
  • 60
  • 75
2

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.

Guna
  • 121
  • 8