There is some specific code to enable GPS, but I have not found it yet.
What I saw online was:
However, this code is in JAVA.
What I was able to mount in Delphi was:
var
poke : JIntent;
begin
poke.setClassName(StringToJString('com.android.settings'),StringToJString('com.android.settings.widget.SettingsAppWidgetProvider'));
poke.addCategory(StringToJString('android.intent.category.ALTERNATIVE'));
poke.setData(TJnet_Uri.JavaClass.parse(StringToJString('3')));
SharedActivity.sendBroadcast(poke);
end;
Second code I got to activate is:
TJSettings_Secure.JavaClass.putString(SharedActivityContext.getContentResolver,
TJSettings_Secure.JavaClass.LOCATION_PROVIDERS_ALLOWED,
TJLocationManager.JavaClass.GPS_PROVIDER);
Third was:
TJSettings_Secure.JavaClass.setLocationProviderEnabled(
SharedActivityContext.getContentResolver,
TJLocationManager.JavaClass.GPS_PROVIDER,
true);
The room was:
Intent := TJIntent.JavaClass.init(TJLocationManager.JavaClass.GPS_PROVIDER);
intent.putExtra(StringToJString('enabled'), true);
SharedActivity.sendBroadcast(intent);
They all need, apparently permission to enable and deal directly with the android settings.
The error I got was (at all):
java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS
In my options, permissions are usually enabled:
NottomentionthatIalsotriedtoputthepermissionsdirectlyontheAndroidManifest.
<uses-permissionandroid:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
Does anyone have any tips to give me?