Seek a common GPS can be used to open the way?
/ / Does not seem to prompt access is not enough, nor
pluspublic void setGpsState ()
{
/ / Open GPS
Settings.Secure.setLocationProviderEnabled (getContentResolver (),
LocationManager.GPS_PROVIDER, true);
}
Online that is needed to root or install the program to System / app
private void setGpsState2 ()
{
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 ();
}
}
This seems to be more than 2.2 can not use
Seeking a universal way, thank you
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
This I have tested, and can be used on 2.2, but can not be used on the 4.0, I'm looking for this information.
Reply:
Please refer to the following
Launcher is not implemented
The key lies in this program database values settings.secure.device_provisioned listen, if we find that the value is set, you can execute our code.
The value of listening, the first to respond android.intent.action.BOOT_COMPLETED broadcast, that is, when the system restarts after the execution. System start after the completion of what action to perform? To monitor the implementation of the corresponding values in the database, specifically is to register an observer, listening for settings.secure.device_provisioned specific code as follows:
context.getContentResolver () registerContentObserver (Settings.Secure.getUriFor (Settings.Secure.DEVICE_PROVISIONED), true, gpsObserver);.
After registering the value of listening to the database, where the response method to the above code, for example, is gpsObserver, the increase in the value of the database is set to:
private ContentObserver gpsObserver = new ContentObserver (new Handler ()) {
@ Override
public void onChange (boolean selfChange) {
if (Settings.Secure.getInt (conText.getContentResolver (), Settings.Secure.DEVICE_PROVISIONED, 0)! = 0) {
Settings.Secure.setLocationProviderEnabled (conText.getContentResolver (), LocationManager.NETWORK_PROVIDER, false);
Settings.Secure.setLocationProviderEnabled (conText.getContentResolver (), LocationManager.GPS_PROVIDER, false);
Intent i = new Intent (ACTION_SET_USE_LOCATION_FOR_SERVICES);
i.setFlags (i.getFlags () | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.putExtra (EXTRA_DISABLE_USE_LOCATION_FOR_SERVICES, true);
conText.startActivity (i);
}
}
}
Reply:
Will solve a thing? Can automatically turn on gps Well?
Reply:
ACTION_SET_USE_LOCATION_FOR_SERVICES
EXTRA_DISABLE_USE_LOCATION_FOR_SERVICES
What is this, an error ah,
ACTION_SET_USE_LOCATION_FOR_SERVICES cannot be resolved to a variable
EXTRA_DISABLE_USE_LOCATION_FOR_SERVICES cannot be resolved to a variable
This constant reference to where to go?
No comments:
Post a Comment