List of usage examples for android.app PendingIntent FLAG_CANCEL_CURRENT
int FLAG_CANCEL_CURRENT
To view the source code for android.app PendingIntent FLAG_CANCEL_CURRENT.
Click Source Link
From source file:com.viking.logking.LogService.java
private PendingIntent getNotificationIntent(String action) { if (action == null) { Intent intent = new Intent(getApplicationContext(), MainActivity.class); return PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); } /*else if (action == LogReceiver.ACTION_SHARE) { Intent intent = new Intent(getApplicationContext(), ShareActivity.class); return PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); } */else { Intent intent = new Intent(action); return PendingIntent.getBroadcast(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); }//from w ww. ja v a2 s . c o m }
From source file:com.csipsimple.service.SipNotifications.java
public void showNotificationForCall(SipCallSession callInfo) { // This is the pending call notification // int icon = R.drawable.ic_incall_ongoing; @SuppressWarnings("deprecation") int icon = android.R.drawable.stat_sys_phone_call; CharSequence tickerText = context.getText(R.string.ongoing_call); long when = System.currentTimeMillis(); if (inCallNotification == null) { inCallNotification = new NotificationCompat.Builder(context); inCallNotification.setSmallIcon(icon); inCallNotification.setTicker(tickerText); inCallNotification.setWhen(when); inCallNotification.setOngoing(true); }//from www . j a v a 2s . c om Intent notificationIntent = SipService.buildCallUiIntent(context, callInfo); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); inCallNotification.setContentTitle(formatNotificationTitle(R.string.ongoing_call, callInfo.getAccId())); inCallNotification.setContentText(formatRemoteContactString(callInfo.getRemoteContact())); inCallNotification.setContentIntent(contentIntent); Notification notification = inCallNotification.build(); notification.flags |= Notification.FLAG_NO_CLEAR; notificationManager.notify(CALL_NOTIF_ID, notification); }
From source file:com.atlas.mars.weatherradar.MainActivity.java
void alarmOn() { am = (AlarmManager) getSystemService(Context.ALARM_SERVICE); intent1 = createIntent("action 1", "extra 1", SampleBootReceiver.class); pIntent1 = PendingIntent.getBroadcast(this, 0, intent1, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(pIntent1);//from w w w. ja v a 2 s . co m //todo ?? //am.set(AlarmManager.RTC_WAKEUP, startAlarm, pIntent1); am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1 * 1000, pIntent1); }
From source file:com.readystatesoftware.ghostlog.LogService.java
private PendingIntent getNotificationIntent(String action) { if (action == null) { Intent intent = new Intent(getApplicationContext(), MainActivity.class); return PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); } else if (action == LogReceiver.ACTION_SHARE) { Intent intent = new Intent(getApplicationContext(), ShareActivity.class); return PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); } else {//from w ww .ja va 2 s. c o m Intent intent = new Intent(action); return PendingIntent.getBroadcast(getApplicationContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); } }
From source file:com.newcell.calltext.service.SipNotifications.java
public void showNotificationForCall(SipCallSession callInfo) { // This is the pending call notification // int icon = R.drawable.ic_incall_ongoing; @SuppressWarnings("deprecation") int icon = android.R.drawable.stat_sys_phone_call; CharSequence tickerText = context.getText(R.string.ongoing_call); long when = System.currentTimeMillis(); if (inCallNotification == null) { inCallNotification = new NotificationCompat.Builder(context).setSmallIcon(icon).setTicker(tickerText) .setWhen(when).setOngoing(true); }/* www . j a v a 2s . c o m*/ Intent notificationIntent = SipService.buildCallUiIntent(context, callInfo); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); // PendingIntent endCallIntent = PendingIntent.getActivity(context, 0, notificationIntent, IOnCallActionTrigger.TERMINATE_CALL); // PendingIntent speakerOnIntent = PendingIntent.getActivity(context, 0, notificationIntent, IOnCallActionTrigger.SPEAKER_ON); // PendingIntent speakerOffIntent = PendingIntent.getActivity(context, 0, notificationIntent, IOnCallActionTrigger.SPEAKER_OFF); /* * Change in-call notification here */ inCallNotification.setContentTitle(context.getText(R.string.ongoing_call)); // inCallNotification.setContentTitle(formatNotificationTitle(R.string.ongoing_call, callInfo.getAccId())); // old version inCallNotification.setContentText(SipUri.getDisplayedSimpleContact(callInfo.getRemoteContact())); // inCallNotification.setContentText(formatRemoteContactString(callInfo.getRemoteContact())); // old version /* * */ inCallNotification.setContentIntent(contentIntent); // End call/Speaker buttons on notification // inCallNotification.addAction(R.drawable.ic_lockscreen_decline_normal, "", endCallIntent); // inCallNotification.addAction(R.drawable.ic_speaker_dark, "", speakerOnIntent); Notification notification = inCallNotification.build(); notification.flags |= Notification.FLAG_NO_CLEAR; notificationManager.notify(CALL_NOTIF_ID, notification); }
From source file:com.golden.android.eyecare.ForegroundService.java
void notify(Intent intent) { if (intent.getAction().equals(Constants.ACTION.STARTFOREGROUND_ACTION)) { Log.i(LOG_TAG, "Received Start Foreground Intent "); //// www.ja v a 2s . c o m // Intent notificationIntent = new Intent(this, MainActivity.class); // notificationIntent.setAction(Constants.ACTION.MAIN_ACTION); // notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK // | Intent.FLAG_ACTIVITY_CLEAR_TASK); // PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, // notificationIntent, 0); Intent notificationIntent = new Intent(this, ForegroundService.class); notificationIntent.setAction(Constants.ACTION.STOPFOREGROUND_ACTION); PendingIntent pendingIntent = PendingIntent.getService(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); Intent previousIntent = new Intent(this, ForegroundService.class); previousIntent.setAction(Constants.ACTION.PREV_ACTION); PendingIntent ppreviousIntent = PendingIntent.getService(this, 0, previousIntent, 0); Intent playIntent = new Intent(this, ForegroundService.class); playIntent.setAction(Constants.ACTION.STOPFOREGROUND_ACTION); PendingIntent pplayIntent = PendingIntent.getService(this, 0, playIntent, 0); Intent nextIntent = new Intent(this, ForegroundService.class); nextIntent.setAction(Constants.ACTION.NEXT_ACTION); PendingIntent pnextIntent = PendingIntent.getService(this, 0, nextIntent, 0); Bitmap icon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_eye); Intent dialogIntent = new Intent(getApplicationContext(), Count.class); dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); dialogIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); // startActivity(dialogIntent); PendingIntent pplayIntent1 = PendingIntent.getService(this, 0, dialogIntent, 0); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setContentTitle("Truiton Music Player"); builder.setTicker("Truiton Music Player"); builder.setContentText("My Music"); builder.setSmallIcon(R.drawable.ic_eye); builder.setContentIntent(pendingIntent); builder.setOngoing(false); Notification notification = builder.build(); startForeground(Constants.NOTIFICATION_ID.FOREGROUND_SERVICE, notification); } else if (intent.getAction().equals(Constants.ACTION.STOPFOREGROUND_ACTION)) { Log.i(LOG_TAG, "Received Stop Foreground Intent"); launchCount(); } }
From source file:org.kde.kdeconnect.Device.java
public void displayPairingNotification() { hidePairingNotification();/*www.j a v a2 s . com*/ notificationId = (int) System.currentTimeMillis(); Intent intent = new Intent(getContext(), MaterialActivity.class); intent.putExtra("deviceId", getDeviceId()); intent.putExtra("notificationId", notificationId); PendingIntent pendingIntent = PendingIntent.getActivity(getContext(), 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); Intent acceptIntent = new Intent(getContext(), MaterialActivity.class); Intent rejectIntent = new Intent(getContext(), MaterialActivity.class); acceptIntent.putExtra("deviceId", getDeviceId()); acceptIntent.putExtra("notificationId", notificationId); acceptIntent.setAction("action " + System.currentTimeMillis()); acceptIntent.putExtra(MaterialActivity.PAIR_REQUEST_STATUS, MaterialActivity.PAIRING_ACCEPTED); rejectIntent.putExtra("deviceId", getDeviceId()); rejectIntent.putExtra("notificationId", notificationId); rejectIntent.setAction("action " + System.currentTimeMillis()); rejectIntent.putExtra(MaterialActivity.PAIR_REQUEST_STATUS, MaterialActivity.PAIRING_REJECTED); PendingIntent acceptedPendingIntent = PendingIntent.getActivity(getContext(), 2, acceptIntent, PendingIntent.FLAG_ONE_SHOT); PendingIntent rejectedPendingIntent = PendingIntent.getActivity(getContext(), 4, rejectIntent, PendingIntent.FLAG_ONE_SHOT); Resources res = getContext().getResources(); Notification noti = new NotificationCompat.Builder(getContext()) .setContentTitle(res.getString(R.string.pairing_request_from, getName())) .setContentText(res.getString(R.string.tap_to_answer)).setContentIntent(pendingIntent) .setTicker(res.getString(R.string.pair_requested)).setSmallIcon(R.drawable.ic_notification) .addAction(R.drawable.ic_accept_pairing, res.getString(R.string.pairing_accept), acceptedPendingIntent) .addAction(R.drawable.ic_reject_pairing, res.getString(R.string.pairing_reject), rejectedPendingIntent) .setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).build(); final NotificationManager notificationManager = (NotificationManager) getContext() .getSystemService(Context.NOTIFICATION_SERVICE); NotificationHelper.notifyCompat(notificationManager, notificationId, noti); BackgroundService.addGuiInUseCounter(context); }
From source file:com.atlas.mars.weatherradar.MainActivity.java
void alarmCancel() { if (pIntent1 != null && am != null) { pIntent1 = PendingIntent.getBroadcast(this, 0, intent1, PendingIntent.FLAG_CANCEL_CURRENT); am.cancel(pIntent1);// w ww. j av a 2 s . com } }
From source file:org.ciasaboark.tacere.manager.NotificationManagerWrapper.java
/** * Builds and displays a notification for the given CalEvent. This method uses the older * Notification API, and does not include an action button * * @param event the CalEvent that is currently active. *//*from w w w . jav a 2s .c o m*/ private void displayCompatEventNotification(EventInstance event) { // clicking the notification should take the user to the app Intent notificationIntent = new Intent(context, MainActivity.class); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // FLAG_CANCEL_CURRENT is required to make sure that the extras are including in // the new pending intent PendingIntent pendIntent = PendingIntent.getActivity(context, REQUEST_CODES.EVENT_OPEN_MAIN, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); NotificationCompat.Builder notBuilder = new NotificationCompat.Builder(context) .setContentTitle(context.getString(R.string.notification_event_active_title)) .setContentText(event.toString()).setAutoCancel(false).setOnlyAlertOnce(true).setOngoing(true) .setContentIntent(pendIntent).setColor(context.getResources().getColor(R.color.accent)); EventManager eventManager = new EventManager(context, event); switch (eventManager.getBestRinger()) { case SILENT: notBuilder.setSmallIcon(R.drawable.not_silence); break; case VIBRATE: notBuilder.setSmallIcon(R.drawable.not_vibrate); break; case NORMAL: notBuilder.setSmallIcon(R.drawable.not_normal); break; } // the ticker text should only be shown the first time the notification is // created, not on each update notBuilder .setTicker(context.getString(R.string.notification_event_active_starting) + " " + event.toString()); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(NOTIFICATION_ID, notBuilder.build()); }
From source file:com.hplasplas.reminders.services.NotificationService.java
private PendingIntent createPendingIntent(int id) { Intent intent = new Intent(this.getApplicationContext(), NotificationService.class); intent.putExtra(CURRENT_NOTIFICATION_READ, true); if (id == ACTIVITY_PENDING_INTENT_ID) { intent.putExtra(NEED_ACTIVITY_START, true); }// ww w . ja va 2s . com return PendingIntent.getService(this.getApplicationContext(), id, intent, PendingIntent.FLAG_CANCEL_CURRENT); }