+ Reply to Thread
Results 1 to 2 of 2

Thread: Turn on/off the GPS

  1. #1
    Junior Member
    Join Date
    May 2012
    Posts
    7

    Turn on/off the GPS

    Can you tell me how can i trun off and on the GPS ?

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Posts
    22
    GPS ON
    Code:
    private void GPSON(){
        String ourProvider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
    
        if(!ourProvider.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")); 
            sendBroadcast(poke);
        }
    }
    GPS OFF
    Code:
    private void GPSOFF(){
        String ourProvider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
    
        if(ourProvider.contains("gps")){ //if gps is 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);
        }
    }

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts