I am new to a service
. I want to turn on my GPS sensor and get the lat and long coordinate of GPS. I am using Android M, I provided the permission for my app. However, I cannot enable and get coordinate. Could you help me?
code :
//Enable gps
String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if(!provider.contains("gps")) {
new Handler(getMainLooper()).post(new Runnable() {
@Override
public void run() {
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"));
sendBroadcast(poke);
}
});
}