@Override
 protected void onPause() {
   Logs.d(this, "onPause");
   if (mService != null && mService.getBinder() != null) {
     // unbindService(myConnection);
     doUnbindService();
   }
   super.onPause();
 }
  @Override
  protected void onResume() {
    AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
    Intent i = new Intent(this.getApplicationContext(), MyService.class);
    PendingIntent pi = PendingIntent.getService(this, 0, i, 0);
    am.cancel(pi);
    double minutes = 1;
    // by my own convention, minutes <= 0 means notifications are disabled
    if (minutes > 0) {
      am.setInexactRepeating(
          AlarmManager.RTC_WAKEUP,
          SystemClock.elapsedRealtime() + (long) minutes * 60 * 1000,
          (long) minutes * 60 * 1000,
          pi);
    }

    Logs.d(this, "onResume");
    if (mService == null || mService.getBinder() == null) {
      doBindService();
    }

    super.onResume();
  }
Exemplo n.º 3
0
 @Override
 public IBinder onBind(Intent intent) {
   return messenger.getBinder();
 }
 /** Factory method that returns the underlying IBinder associated with the Request Messenger. */
 @Override
 public IBinder onBind(Intent intent) {
   super.onBind(intent);
   // Return the iBinder associated with the Request Messenger.
   return mRequestMessenger.getBinder();
 }
 // no binding allowed for this, so return null
 public IBinder getBinder() {
   return mServerMessenger.getBinder();
 }
Exemplo n.º 6
0
 @Override
 public IBinder onBind(Intent intent) {
   Log.d(LogUtil.TAG, "JoyplusSearchService onBind");
   return messenger.getBinder();
 }
 /**
  * When binding to the service, we return an interface to our messenger for sending messages to
  * the service.
  */
 @Override
 public IBinder onBind(Intent intent) {
   Log.i(TAG, "binding");
   bindCount++;
   return mMessenger.getBinder();
 }
Exemplo n.º 8
0
 public void testGetBinder() {
   Messenger messenger = new Messenger(mIBinder);
   assertSame(mIBinder, messenger.getBinder());
   assertNotNull(mMessenger.getBinder());
 }
Exemplo n.º 9
0
 public void testHashCode() {
   assertEquals(mMessenger.getBinder().hashCode(), mMessenger.hashCode());
 }
Exemplo n.º 10
0
 @Override
 public IBinder onBind(final Intent intent) {
   FLog.i(TAG, "onBind");
   mFrontMessenger = null;
   return mMessenger.getBinder();
 }
Exemplo n.º 11
0
 @Override
 public IBinder onBind(Intent intent) {
   Toast.makeText(this, "Service bounded", Toast.LENGTH_SHORT).show();
   return mMessenger.getBinder();
 }
Exemplo n.º 12
0
 @Override
 public IBinder onBind(Intent intent) {
   Log.i(LOGTAG, "onBind");
   return mMessenger.getBinder();
 }
Exemplo n.º 13
0
 public IBinder getBinder() {
   mIsBound = true;
   return mSelfMessenger.getBinder();
 }