Beispiel #1
0
  public void peticionPost() {

    // Ejecutamos el servicio-obtener-posiciones
    Log.d("TabsActivity", "Tab Actual: " + mViewPager.getCurrentItem());
    if (recuperarPreferenciaBoolean("servicio2") && mViewPager.getCurrentItem() == 2) {
      if (sp == null || sp.isCancelled()) {
        sp = new ServicioPosiciones(this, 30000);
        sp.execute();
      }
    } else {
      if (sp != null) {
        sp.cancel(true);
      }
    }
  }
Beispiel #2
0
 @Override
 protected void onDestroy() {
   super.onDestroy();
   if (sp != null) {
     sp.cancel(true);
   }
 }
Beispiel #3
0
  @Override
  public void onPageSelected(int position) {

    Log.d("TabsActivity", "Tab: " + position);

    if (position == 2) {
      peticionPost();
    } else {
      if (sp != null) {
        sp.cancel(true);
      }
    }
  }
Beispiel #4
0
 @Override
 protected void onPause() {
   super.onPause();
   if (sp != null) {
     sp.cancel(true);
   }
   if (gcmReceiver != null) {
     Log.i("deactivate::", "clicked");
     Intent unregIntent = new Intent("com.google.android.c2dm.intent.UNREGISTER");
     Log.i("intent::", "created");
     unregIntent.putExtra(
         "app", PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(), 0));
     startService(unregIntent);
     unregisterReceiver(gcmReceiver);
     gcmReceiver = null;
   }
 }