How can I monitor the status of the GPS adapter using Android SDK?

前端 未结 1 875
时光取名叫无心
时光取名叫无心 2021-01-06 15:55

I need to have my app monitor whether the GPS adapter is anabled or disabled. I don\'t care about the actual GPS functionality running at the monemt or not -- I need the sta

相关标签:
1条回答
  • 2021-01-06 16:19

    LocationContentObserver Nevermind, I found the answer;

    getContentResolver().registerContentObserver(
        Settings.Secure.getUriFor(Settings.System.LOCATION_PROVIDERS_ALLOWED), 
                false, 
                new LocationContentObserver ( new Handler())
        );
    
    class LocationContentObserver extends ContentObserver {
      public LocationContentObserver( Handler h ) {
        super( h );
      }
    
      public void onChange(boolean selfChange) {
          SendNotification(false);
      }
    }
    
    0 讨论(0)
提交回复
热议问题