tags:

views:

34

answers:

1

Anybody know how to enable the GPS setting automatic? Seems the "Toggle Settings" app can handle it, but I want to force open in my app sdk 2.1. some people said

 "Method m =locationManager.getClass().getMethod("updateProviders", new Class[] {});
                m.setAccessible(true);
                m.invoke(locationManager, new Object[]{});"

but in sdk2.1 locationManager class donot have updateProviders. couled you give me some directions or code?

Please help me if you have time.

+1  A: 

Ordinary SDK applications cannot change the GPS enabled state. Only those signed by the firmware signing key can do this, via Settings.Secure.

CommonsWare
Don't reflect cannot use? i want to use reflect,
pengwang
@pengwang: Reflection cannot help, and if it does, it is a security flaw in Android that needs to be fixed. If the user disables GPS, please abide by that user's wishes.
CommonsWare