List of usage examples for android.app AlarmManager cancel
public void cancel(OnAlarmListener listener)
From source file:org.mozilla.gecko.updater.UpdateService.java
private void registerForUpdates(boolean isRetry) { Calendar lastAttempt = getLastAttemptDate(); Calendar now = new GregorianCalendar(TimeZone.getTimeZone("GMT")); int interval = getUpdateInterval(isRetry); if (lastAttempt == null || (now.getTimeInMillis() - lastAttempt.getTimeInMillis()) > interval) { // We've either never attempted an update, or we are passed the desired // time. Start an update now. Log.i(LOGTAG, "no update has ever been attempted, checking now"); startUpdate(0);//w w w .j a v a2s . co m return; } AlarmManager manager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); if (manager == null) return; PendingIntent pending = PendingIntent.getService(this, 0, new Intent(UpdateServiceHelper.ACTION_CHECK_FOR_UPDATE, null, this, UpdateService.class), PendingIntent.FLAG_UPDATE_CURRENT); manager.cancel(pending); lastAttempt.setTimeInMillis(lastAttempt.getTimeInMillis() + interval); Log.i(LOGTAG, "next update will be at: " + lastAttempt.getTime()); manager.set(AlarmManager.RTC_WAKEUP, lastAttempt.getTimeInMillis(), pending); }
From source file:com.androidinspain.deskclock.alarms.AlarmStateManager.java
/** * Used in L and later devices where "next alarm" is stored in the Alarm Manager. *//*from w w w . j av a 2 s .c o m*/ @TargetApi(Build.VERSION_CODES.LOLLIPOP) private static void updateNextAlarmInAlarmManager(Context context, AlarmInstance nextAlarm) { // Sets a surrogate alarm with alarm manager that provides the AlarmClockInfo for the // alarm that is going to fire next. The operation is constructed such that it is ignored // by AlarmStateManager. final AlarmManager alarmManager = (AlarmManager) context.getSystemService(ALARM_SERVICE); final int flags = nextAlarm == null ? PendingIntent.FLAG_NO_CREATE : 0; final PendingIntent operation = PendingIntent.getBroadcast(context, 0 /* requestCode */, AlarmStateManager.createIndicatorIntent(context), flags); if (nextAlarm != null) { LogUtils.i("Setting upcoming AlarmClockInfo for alarm: " + nextAlarm.mId); long alarmTime = nextAlarm.getAlarmTime().getTimeInMillis(); // Create an intent that can be used to show or edit details of the next alarm. PendingIntent viewIntent = PendingIntent.getActivity(context, nextAlarm.hashCode(), AlarmNotifications.createViewAlarmIntent(context, nextAlarm), PendingIntent.FLAG_UPDATE_CURRENT); final AlarmClockInfo info = new AlarmClockInfo(alarmTime, viewIntent); Utils.updateNextAlarm(alarmManager, info, operation); } else if (operation != null) { LogUtils.i("Canceling upcoming AlarmClockInfo"); alarmManager.cancel(operation); } }
From source file:org.voidsink.anewjkuapp.utils.AppUtils.java
public static void updateSyncAlarm(Context context, boolean reCreateAlarm) { boolean mIsCalendarSyncEnabled = false; boolean mIsKusssSyncEnable = false; boolean mIsMasterSyncEnabled = ContentResolver.getMasterSyncAutomatically(); if (mIsMasterSyncEnabled) { final Account mAccount = getAccount(context); if (mAccount != null) { mIsCalendarSyncEnabled = ContentResolver.getSyncAutomatically(mAccount, CalendarContractWrapper.AUTHORITY()); mIsKusssSyncEnable = ContentResolver.getSyncAutomatically(mAccount, KusssContentContract.AUTHORITY); }// ww w.java2s.co m } Log.d(TAG, String.format("MasterSync=%b, CalendarSync=%b, KusssSync=%b", mIsMasterSyncEnabled, mIsCalendarSyncEnabled, mIsKusssSyncEnable)); AlarmManager am = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); Intent intent = new Intent(context, SyncAlarmService.class); intent.putExtra(Consts.ARG_UPDATE_CAL, !mIsCalendarSyncEnabled); intent.putExtra(Consts.ARG_UPDATE_KUSSS, !mIsKusssSyncEnable); intent.putExtra(Consts.ARG_RECREATE_SYNC_ALARM, true); intent.putExtra(Consts.SYNC_SHOW_PROGRESS, true); // check if pending intent exists reCreateAlarm = reCreateAlarm || (PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_NO_CREATE) == null); // new pending intent PendingIntent alarmIntent = PendingIntent.getService(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); if (!mIsMasterSyncEnabled || !mIsCalendarSyncEnabled || !mIsKusssSyncEnable) { if (reCreateAlarm) { long interval = PreferenceWrapper.getSyncInterval(context) * DateUtils.HOUR_IN_MILLIS; // synchronize in half an hour am.setInexactRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + AlarmManager.INTERVAL_HALF_HOUR, interval, alarmIntent); } } else { am.cancel(alarmIntent); } }
From source file:com.first.akashshrivastava.showernow.ShowerActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_shower_activity); /*Launching BootReceiver to test Intent playIntent = new Intent(getApplicationContext(), BootReceiver.class); startActivity(playIntent);/* w ww .j av a 2 s . c o m*/ */ //Mobile ads initialization....The long number is the AdID, can be found on AdMob - ca-app-pub-8782530512283806/2988799979 MobileAds.initialize(getApplicationContext(), "ca-app-pub-8782530512283806/2988799979"); AdView mAdView = (AdView) findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().build(); mAdView.loadAd(adRequest); //Facebook SDK initialization... FacebookSdk.sdkInitialize(getApplicationContext()); AppEventsLogger.activateApp(this); shareDialog = new ShareDialog(this); mDatabaseReference = FirebaseDatabase.getInstance().getReference(); mFirebaseAuth = FirebaseAuth.getInstance(); final ImageView genderImage = (ImageView) findViewById(R.id.imageGender); guyText = (TextView) findViewById(R.id.guyText); topText = (TextView) findViewById(R.id.textView2); SharedPreferences prefs = getSharedPreferences("myPrefs", Context.MODE_PRIVATE); extraAge = prefs.getInt("age", 0); extraFluffiness = prefs.getString("fluffiness", ""); extraGender = prefs.getString("gender", ""); extraOldTime = prefs.getLong("time", 0); extraSteps = prefs.getFloat("stepsBoot", 0); switch (extraGender) { case "male": genderImage.setImageResource(R.drawable.male_white_outline); break; case "female": genderImage.setImageResource(R.drawable.female_white_outline); break; case "other": genderImage.setImageResource(R.drawable.other_white_outline); break; } genderImage.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { //set alarm //Swith ccase switch (event.getAction()) { case MotionEvent.ACTION_UP: // PRESSED ..PRESSED if (genderImage.getDrawable().getConstantState() == getResources() .getDrawable(R.drawable.female_white_outline_pressed).getConstantState()) { genderImage.setImageResource(R.drawable.female_white_outline); } else if (genderImage.getDrawable().getConstantState() == getResources() .getDrawable(R.drawable.male_white_outline_pressed).getConstantState()) { genderImage.setImageResource(R.drawable.male_white_outline); } else if (genderImage.getDrawable().getConstantState() == getResources() .getDrawable(R.drawable.other_white_outline_pressed).getConstantState()) { genderImage.setImageResource(R.drawable.other_white_outline); } //Resets the wave after shower..this is not getting called for some reason.... waveProgressbar.setCurrent(0, ""); guyText.setText("0 %"); waveProgressbar.setVisibility(View.INVISIBLE); topText.setText("You have showered! \n When the wave hits 100% its time for your next shower "); if (fluffiness != null && gotSteps) { Calendar cal = Calendar.getInstance(); Intent activate = new Intent(ShowerActivity.this, AlarmReceiver.class); activate.putExtra("age", age); activate.putExtra("fluffiness", fluffiness); activate.putExtra("gender", gender); activate.putExtra("steps", steps); activate.putExtra("time", System.currentTimeMillis()); AlarmManager alarms; PendingIntent alarmIntent = PendingIntent.getBroadcast(ShowerActivity.this, 0, activate, FLAG_CANCEL_CURRENT); alarms = (AlarmManager) getSystemService(ALARM_SERVICE); alarms.cancel(alarmIntent); alarms.setRepeating(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis() + 5000, 1000 * 60, alarmIntent);//sets the alarm mDatabaseReference.child("User").child(mFirebaseAuth.getCurrentUser().getUid()) .child("Steps").setValue(steps);//sets old steps oldSteps = steps; mDatabaseReference.child("User").child(mFirebaseAuth.getCurrentUser().getUid()) .child("Time").setValue(System.currentTimeMillis()); oldTime = System.currentTimeMillis(); newUser = false; SharedPreferences sharedPref = getSharedPreferences("myPrefs", Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt("age", age); editor.putString("fluffiness", fluffiness); editor.putString("gender", gender); editor.putFloat("steps", steps); editor.putLong("time", System.currentTimeMillis()); editor.putFloat("stepsBoot", 0); editor.putBoolean("bootStart", true); editor.apply(); } else if (!gotSteps) { Toast.makeText(getApplicationContext(), "Waiting for steps", Toast.LENGTH_SHORT).show(); } return true; // if you want to handle the touch event case MotionEvent.ACTION_DOWN: // RELEASED..RELEASED.. if (genderImage.getDrawable().getConstantState() == getResources() .getDrawable(R.drawable.female_white_outline).getConstantState()) { genderImage.setImageResource(R.drawable.female_white_outline_pressed); } else if (genderImage.getDrawable().getConstantState() == getResources() .getDrawable(R.drawable.male_white_outline).getConstantState()) { genderImage.setImageResource(R.drawable.male_white_outline_pressed); } else if (genderImage.getDrawable().getConstantState() == getResources() .getDrawable(R.drawable.other_white_outline).getConstantState()) { genderImage.setImageResource(R.drawable.other_white_outline_pressed); } return true; // if you want to handle the touch event } //Switch case end bracket return false; } }); createWave(); setMenuColor(); setupStepcount(); setWaveHeight(); FloatingActionButton editDetails = (FloatingActionButton) findViewById(R.id.menu_item4); //edit user information. Goes to main activity editDetails.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { /* Fragment fragment = new Fragment(); FragmentTransaction transaction = manager.beginTransaction(); transaction.add(ShowerActivity.java); transaction.addToBackStack(ShowerActivity.java); transaction.commit(); */ //Fragment B at pos 2 should open when edit details is pressed.. Intent i = new Intent(ShowerActivity.this, MainActivity.class); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); } }); FloatingActionButton fabmenuDeleteAccount = (FloatingActionButton) findViewById(R.id.delete_Account); fabmenuDeleteAccount.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog(); } }); FloatingActionButton fabMenuItem1 = (FloatingActionButton) findViewById(R.id.menu_item); fabMenuItem1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { /*ComponentName receiver = new ComponentName(ShowerActivity.this, AlarmReceiver.class); // alarms.cancel(alarmIntent);?? PackageManager pm = ShowerActivity.this.getPackageManager(); pm.setComponentEnabledSetting(receiver, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); stopService(new Intent(StepCountService.STEP_COUNT_SERVICE));*/ //mFirebaseAuth.getCurrentUser().getUid() =null; SharedPreferences sharedPref = getSharedPreferences("myPrefs", Context.MODE_PRIVATE); SharedPreferences.Editor editor = sharedPref.edit(); editor.putInt("age", 0); editor.putString("fluffiness", ""); editor.putString("gender", ""); editor.putFloat("steps", 0); editor.putLong("time", 0); editor.putFloat("stepsBoot", 0); editor.putBoolean("bootStart", false); editor.apply(); Intent activate = new Intent(ShowerActivity.this, AlarmReceiver.class); PendingIntent alarmIntent = PendingIntent.getBroadcast(ShowerActivity.this, 0, activate, FLAG_CANCEL_CURRENT); AlarmManager alarms = (AlarmManager) getSystemService(ALARM_SERVICE); alarms.cancel(alarmIntent); stopService(new Intent(ShowerActivity.this, StepCountService.class)); mFirebaseAuth.getInstance().signOut(); Intent i = new Intent(ShowerActivity.this, LoginActivity.class); startActivity(i); } }); final FloatingActionButton shareButton = (FloatingActionButton) findViewById(R.id.shareButton); shareButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); String shareBody = "Check out this showering app at: https://play.google.com/store/apps/details?id=com.first.akashshrivastava.showernow \n"; String shareSubString = "An app that tells you when you should shower and apparently keeps you clean"; shareIntent.putExtra(Intent.EXTRA_SUBJECT, shareSubString); shareIntent.putExtra(Intent.EXTRA_TEXT, shareBody); startActivity(Intent.createChooser(shareIntent, " Share using the following")); } }); mDatabaseReference.addListenerForSingleValueEvent(new ValueEventListener() { @Override public void onDataChange(DataSnapshot snap) { try { if ((!(mFirebaseAuth.getCurrentUser().getUid().isEmpty())) && snap.child("User").child(mFirebaseAuth.getCurrentUser().getUid()).child("gender") .getValue().toString().equalsIgnoreCase("female")) { genderImage.setImageResource(R.drawable.female_white_outline); } else if (snap.child("User").child(mFirebaseAuth.getCurrentUser().getUid()).child("gender") .getValue().toString().equalsIgnoreCase("male")) { genderImage.setImageResource(R.drawable.male_white_outline); } else if (snap.child("User").child(mFirebaseAuth.getCurrentUser().getUid()).child("gender") .getValue().toString().equalsIgnoreCase("other")) { genderImage.setImageResource(R.drawable.other_white_outline); } } catch (Exception e) { e.printStackTrace(); } age = Integer.parseInt(snap.child("User").child(mFirebaseAuth.getCurrentUser().getUid()) .child("Age").getValue().toString());//gotta get int fluffiness = snap.child("User").child(mFirebaseAuth.getCurrentUser().getUid()).child("gender") .getValue().toString(); gender = snap.child("User").child(mFirebaseAuth.getCurrentUser().getUid()).child("gender") .getValue().toString(); if (snap.child("User").child(mFirebaseAuth.getCurrentUser().getUid()).child("Time").exists()) { oldTime = snap.child("User").child(mFirebaseAuth.getCurrentUser().getUid()).child("Time") .getValue(Long.class); oldSteps = snap.child("User").child(mFirebaseAuth.getCurrentUser().getUid()).child("Steps") .getValue(float.class); } else { newUser = true; } } @Override public void onCancelled(DatabaseError databaseError) { } }); }
From source file:cw.kop.autobackground.sources.SourceListFragment.java
/** * Starts (or stops) download and sets download icon appropriately *//*w ww. j a v a 2 s . c om*/ private void startDownload() { listAdapter.saveData(); if (FileHandler.isDownloading) { DialogFactory.ActionDialogListener listener = new DialogFactory.ActionDialogListener() { @Override public void onClickRight(View v) { FileHandler.cancel(appContext); resetActionBarDownload(); dismissDialog(); } }; DialogFactory.showActionDialog(appContext, "", "Cancel download?", listener, -1, R.string.cancel_button, R.string.ok_button); } else if (FileHandler.download(appContext)) { Drawable drawable = getResources().getDrawable(R.drawable.ic_cancel_white_24dp); drawable.setColorFilter(AppSettings.getColorFilterInt(appContext), PorterDuff.Mode.MULTIPLY); toolbarMenu.getItem(1).setIcon(drawable); if (AppSettings.resetOnManualDownload() && AppSettings.useTimer() && AppSettings.getTimerDuration() > 0) { Intent intent = new Intent(); intent.setAction(LiveWallpaperService.DOWNLOAD_WALLPAPER); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); PendingIntent pendingIntent = PendingIntent.getBroadcast(appContext, 0, intent, 0); AlarmManager alarmManager = (AlarmManager) appContext.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(pendingIntent); alarmManager.setInexactRepeating(AlarmManager.RTC, System.currentTimeMillis() + AppSettings.getTimerDuration(), AppSettings.getTimerDuration(), pendingIntent); } } }
From source file:uk.bowdlerize.service.CensorCensusService.java
private void onProbeFinish() { AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); Intent i = new Intent(CensorCensusService.this, CensorCensusService.class); i.putExtra(API.EXTRA_POLL, true);/*from w w w . ja va 2 s . c o m*/ PendingIntent pi = PendingIntent.getService(CensorCensusService.this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); //If we are polling lets set our next tick if (getSharedPreferences(MainActivity.class.getSimpleName(), Context.MODE_PRIVATE) .getInt(API.SETTINGS_GCM_PREFERENCE, API.SETTINGS_GCM_FULL) == API.SETTINGS_GCM_DISABLED) { am.cancel(pi); // cancel any existing alarms //TODO Setback to 60000 long repeat = (long) (getPreferences(CensorCensusService.this).getInt(API.SETTINGS_FREQUENCY, 1) * 60000);//60000 or 5000 Log.e("onProbeFinish", Long.toString(repeat)); Log.e("onProbeFinish", " - "); Log.e("onProbeFinish", " - "); Log.e("onProbeFinish", " - "); am.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + repeat, pi); } else { Log.e("onProbeFinish", "Cancel everything!"); Log.e("onProbeFinish", " - "); Log.e("onProbeFinish", " - "); Log.e("onProbeFinish", " - "); am.cancel(pi); // cancel any existing alarms stopSelf(); } }
From source file:org.telegram.ui.CacheControlActivity.java
@Override public View createView(Context context) { actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setAllowOverlayTitle(true); actionBar.setTitle(LocaleController.getString("CacheSettings", R.string.CacheSettings)); actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() { @Override/* w w w . j a va2s. co m*/ public void onItemClick(int id) { if (id == -1) { finishFragment(); } } }); listAdapter = new ListAdapter(context); fragmentView = new FrameLayout(context); FrameLayout frameLayout = (FrameLayout) fragmentView; frameLayout.setBackgroundColor(ContextCompat.getColor(context, R.color.settings_background)); ListView listView = new ListView(context); listView.setDivider(null); listView.setDividerHeight(0); listView.setVerticalScrollBarEnabled(false); listView.setDrawSelectorOnTop(true); frameLayout.addView(listView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); listView.setAdapter(listAdapter); listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> adapterView, View view, final int i, long l) { if (getParentActivity() == null) { return; } if (i == keepMediaRow) { BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity()); builder.setItems( new CharSequence[] { LocaleController.formatPluralString("Weeks", 1), LocaleController.formatPluralString("Months", 1), LocaleController.getString("KeepMediaForever", R.string.KeepMediaForever) }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, final int which) { SharedPreferences.Editor editor = ApplicationLoader.applicationContext .getSharedPreferences("mainconfig", Activity.MODE_PRIVATE).edit(); editor.putInt("keep_media", which).commit(); if (listAdapter != null) { listAdapter.notifyDataSetChanged(); } PendingIntent pintent = PendingIntent.getService( ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, ClearCacheService.class), 0); AlarmManager alarmManager = (AlarmManager) ApplicationLoader.applicationContext .getSystemService(Context.ALARM_SERVICE); if (which == 2) { alarmManager.cancel(pintent); } else { alarmManager.setInexactRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, AlarmManager.INTERVAL_DAY, AlarmManager.INTERVAL_DAY, pintent); } } }); showDialog(builder.create()); } else if (i == databaseRow) { AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); builder.setMessage( LocaleController.getString("LocalDatabaseClear", R.string.LocalDatabaseClear)); builder.setPositiveButton(LocaleController.getString("CacheClear", R.string.CacheClear), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { final ProgressDialog progressDialog = new ProgressDialog(getParentActivity()); progressDialog .setMessage(LocaleController.getString("Loading", R.string.Loading)); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); progressDialog.show(); MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() { @Override public void run() { try { SQLiteDatabase database = MessagesStorage.getInstance() .getDatabase(); ArrayList<Long> dialogsToCleanup = new ArrayList<>(); SQLiteCursor cursor = database .queryFinalized("SELECT did FROM dialogs WHERE 1"); StringBuilder ids = new StringBuilder(); while (cursor.next()) { long did = cursor.longValue(0); int lower_id = (int) did; int high_id = (int) (did >> 32); if (lower_id != 0 && high_id != 1) { dialogsToCleanup.add(did); } } cursor.dispose(); SQLitePreparedStatement state5 = database .executeFast("REPLACE INTO messages_holes VALUES(?, ?, ?)"); SQLitePreparedStatement state6 = database.executeFast( "REPLACE INTO media_holes_v2 VALUES(?, ?, ?, ?)"); database.beginTransaction(); for (int a = 0; a < dialogsToCleanup.size(); a++) { Long did = dialogsToCleanup.get(a); int messagesCount = 0; cursor = database.queryFinalized( "SELECT COUNT(mid) FROM messages WHERE uid = " + did); if (cursor.next()) { messagesCount = cursor.intValue(0); } cursor.dispose(); if (messagesCount <= 2) { continue; } cursor = database.queryFinalized( "SELECT last_mid_i, last_mid FROM dialogs WHERE did = " + did); int messageId = -1; if (cursor.next()) { long last_mid_i = cursor.longValue(0); long last_mid = cursor.longValue(1); SQLiteCursor cursor2 = database.queryFinalized( "SELECT data FROM messages WHERE uid = " + did + " AND mid IN (" + last_mid_i + "," + last_mid + ")"); try { while (cursor2.next()) { NativeByteBuffer data = cursor2.byteBufferValue(0); if (data != null) { TLRPC.Message message = TLRPC.Message .TLdeserialize(data, data.readInt32(false), false); data.reuse(); if (message != null) { messageId = message.id; } } } } catch (Exception e) { FileLog.e("tmessages", e); } cursor2.dispose(); database.executeFast("DELETE FROM messages WHERE uid = " + did + " AND mid != " + last_mid_i + " AND mid != " + last_mid).stepThis().dispose(); database.executeFast( "DELETE FROM messages_holes WHERE uid = " + did) .stepThis().dispose(); database.executeFast( "DELETE FROM bot_keyboard WHERE uid = " + did) .stepThis().dispose(); database.executeFast( "DELETE FROM media_counts_v2 WHERE uid = " + did) .stepThis().dispose(); database.executeFast( "DELETE FROM media_v2 WHERE uid = " + did) .stepThis().dispose(); database.executeFast( "DELETE FROM media_holes_v2 WHERE uid = " + did) .stepThis().dispose(); BotQuery.clearBotKeyboard(did, null); if (messageId != -1) { MessagesStorage.createFirstHoles(did, state5, state6, messageId); } } cursor.dispose(); } state5.dispose(); state6.dispose(); database.commitTransaction(); database.executeFast("VACUUM").stepThis().dispose(); } catch (Exception e) { FileLog.e("tmessages", e); } finally { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { try { progressDialog.dismiss(); } catch (Exception e) { FileLog.e("tmessages", e); } if (listAdapter != null) { File file = new File( ApplicationLoader.getFilesDirFixed(), "cache4.db"); databaseSize = file.length(); listAdapter.notifyDataSetChanged(); } } }); } } }); } }); showDialog(builder.create()); } else if (i == cacheRow) { if (totalSize <= 0 || getParentActivity() == null) { return; } BottomSheet.Builder builder = new BottomSheet.Builder(getParentActivity()); builder.setApplyTopPadding(false); builder.setApplyBottomPadding(false); LinearLayout linearLayout = new LinearLayout(getParentActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); for (int a = 0; a < 6; a++) { long size = 0; String name = null; if (a == 0) { size = photoSize; name = LocaleController.getString("LocalPhotoCache", R.string.LocalPhotoCache); } else if (a == 1) { size = videoSize; name = LocaleController.getString("LocalVideoCache", R.string.LocalVideoCache); } else if (a == 2) { size = documentsSize; name = LocaleController.getString("LocalDocumentCache", R.string.LocalDocumentCache); } else if (a == 3) { size = musicSize; name = LocaleController.getString("LocalMusicCache", R.string.LocalMusicCache); } else if (a == 4) { size = audioSize; name = LocaleController.getString("LocalAudioCache", R.string.LocalAudioCache); } else if (a == 5) { size = cacheSize; name = LocaleController.getString("LocalCache", R.string.LocalCache); } if (size > 0) { clear[a] = true; CheckBoxCell checkBoxCell = new CheckBoxCell(getParentActivity()); checkBoxCell.setTag(a); checkBoxCell.setBackgroundResource(R.drawable.list_selector); linearLayout.addView(checkBoxCell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48)); checkBoxCell.setText(name, AndroidUtilities.formatFileSize(size), true, true); checkBoxCell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CheckBoxCell cell = (CheckBoxCell) v; int num = (Integer) cell.getTag(); clear[num] = !clear[num]; cell.setChecked(clear[num], true); } }); } else { clear[a] = false; } } BottomSheet.BottomSheetCell cell = new BottomSheet.BottomSheetCell(getParentActivity(), 1); cell.setBackgroundResource(R.drawable.list_selector); cell.setTextAndIcon( LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache).toUpperCase(), 0); cell.setTextColor(Theme.STICKERS_SHEET_REMOVE_TEXT_COLOR); cell.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { if (visibleDialog != null) { visibleDialog.dismiss(); } } catch (Exception e) { FileLog.e("tmessages", e); } cleanupFolders(); } }); linearLayout.addView(cell, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48)); builder.setCustomView(linearLayout); showDialog(builder.create()); } } }); return fragmentView; }
From source file:com.geotrackin.gpslogger.GpsLoggingService.java
private void CancelAlarm() { tracer.debug("."); if (alarmIntent != null) { AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); PendingIntent sender = PendingIntent.getBroadcast(this, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); tracer.debug("Pending alarm intent was null? " + String.valueOf(sender == null)); am.cancel(sender); }//from w ww. jav a 2 s. com }
From source file:com.partypoker.poker.engagement.reach.EngagementReachAgent.java
/** * Called when download has been completed. * @param content content./*from www.j a va 2 s . c o m*/ */ void onDownloadComplete(EngagementReachInteractiveContent content) { /* Cancel alarm */ Intent intent = new Intent(INTENT_ACTION_DOWNLOAD_TIMEOUT); intent.setPackage(mContext.getPackageName()); int requestCode = (int) content.getLocalId(); PendingIntent operation = PendingIntent.getBroadcast(mContext, requestCode, intent, 0); AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); alarmManager.cancel(operation); /* Update notification if not too late e.g. notification not yet dismissed */ notifyPendingContent(content); }
From source file:com.crearo.gpslogger.GpsLoggingService.java
private void cancelAlarm() { if (alarmIntent != null) { AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE); PendingIntent sender = PendingIntent.getBroadcast(this, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); am.cancel(sender); }/*from w ww. j a v a 2 s. co m*/ }