Will Daniel, I made an application, you need to open automatically GPS, use the online method, not
Settings.Secure.setLocationProviderEnabled (getContentResolver (), LocationManager.GPS_PROVIDER, true);
This requires android.permission.WRITE_SECURE_SETTINGS permission but this privilege only to system applications
There are 1,
locationManager.setTestProviderEnabled (android.location.LocationManager.GPS_PROVIDER, true);
2,
Intent GPSIntent = new Intent (); GPSIntent.setClassName ("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
GPSIntent.addCategory ("android.intent.category.ALTERNATIVE");
GPSIntent.setData (Uri.parse ("custom: 3"));
try {
PendingIntent.getBroadcast (this, 0, GPSIntent, 0) send ();.
} Catch (CanceledException e) {
e.printStackTrace ();
} 3,
Intent intent = new Intent ("android.location.GPS_ENABLED_CHANGE");
intent.putExtra ("enabled", true);
this.sendBroadcast (intent);
Stringprovider = Settings.Secure.getString (getContentResolver (), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if (! provider.contains ("gps")) {/ / if gps is disabled
final Intent poke = new Intent ();
poke.setClassName ("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");
poke.addCategory (Intent.CATEGORY_ALTERNATIVE);
poke.setData (Uri.parse ("3"));
this.sendBroadcast (poke);
} The above methods are tried not simulator is 4.0.3, please help me to a large cattle<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Their top, seeking attention
Reply:
Your program is not enough to automatically turn on the GPS is not compatible, do not know the previous 2.2 can not automatically open or not after 2.2 can automatically open a recommended base station location
Reply:
Hello, this is not compatible because of what I saw on the Internet a good idea, do not have a mobile phone interface controls can be small Open the GPS, there is no possibility to call the control aspects of the code, to achieve indirect automatically open the GPS, this can be achieved without? There are positioning themselves before the base station did not get off, there is no information, give some to learn about gratitude!
Reply:
No comments:
Post a Comment