android - How to enable GPS automatically -


i using code security exception.

private void turngpson(){     string provider = settings.secure.getstring(getcontentresolver(), settings.secure.location_providers_allowed); if(!provider.contains("gps")){ //if gps 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"));      sendbroadcast(poke); } }  private void turngpsoff(){     string provider = settings.secure.getstring(getcontentresolver(), settings.secure.location_providers_allowed);  if(provider.contains("gps")){ //if gps enabled     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); } } 

how fix problem automatic enable gps.

for security purpose google developer has block above both methods working fine. cant enable gps programatically


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -