@Override
        public void onReceive(Context context, Intent intent) {
          if (Intent.ACTION_AIRPLANE_MODE_CHANGED.equals(intent.getAction())
              && !intent.getBooleanExtra("state", false)) {
            // Airplane mode is now off!
            mLocationHandler.requestLocationUpdate();
            return;
          }

          // Time zone has changed or alarm expired.
          mLocationHandler.requestTwilightUpdate();
        }
Beispiel #2
0
 public void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.main);
   InitViews();
   lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
   LocationHandler.startGps(lm);
 }
  /**
   * Listens for twilight time.
   *
   * @param listener The listener.
   * @param handler The handler on which to post calls into the listener.
   */
  public void registerListener(TwilightListener listener, Handler handler) {
    synchronized (mLock) {
      mListeners.add(new TwilightListenerRecord(listener, handler));

      if (mSystemReady && mListeners.size() == 1) {
        mLocationHandler.enableLocationUpdates();
      }
    }
  }
  void systemReady() {
    synchronized (mLock) {
      mSystemReady = true;

      IntentFilter filter = new IntentFilter(Intent.ACTION_AIRPLANE_MODE_CHANGED);
      filter.addAction(Intent.ACTION_TIME_CHANGED);
      filter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
      filter.addAction(ACTION_UPDATE_TWILIGHT_STATE);
      mContext.registerReceiver(mUpdateLocationReceiver, filter);

      if (!mListeners.isEmpty()) {
        mLocationHandler.enableLocationUpdates();
      }
    }
  }
Beispiel #5
0
 private void goBack() {
   LocationHandler.stopGps(lm);
   super.onBackPressed();
 }
 public void onLocationChanged(Location location) {
   mLocationHandler.processNewLocation(location);
 }