List of usage examples for android.app PendingIntent FLAG_UPDATE_CURRENT
int FLAG_UPDATE_CURRENT
To view the source code for android.app PendingIntent FLAG_UPDATE_CURRENT.
Click Source Link
From source file:com.appdevper.mediaplayer.app.MusicService.java
@Override public void onCreate() { super.onCreate(); Log.d(TAG, "onCreate"); mPlayingQueue = new ArrayList<>(); mMusicProvider = MusicProvider.getInstance(); QueueManager queueManager = new QueueManager(mMusicProvider, getResources(), new QueueManager.MetadataUpdateListener() { @Override//from w ww . j a va2 s . co m public void onMetadataChanged(MediaMetadataCompat metadata) { mSession.setMetadata(metadata); } @Override public void onMetadataRetrieveError() { mPlaybackManager.updatePlaybackState(getString(R.string.error_no_metadata)); } @Override public void onCurrentQueueIndexUpdated(int queueIndex) { mPlaybackManager.handlePlayRequest(); } @Override public void onQueueUpdated(String title, List<MediaSessionCompat.QueueItem> newQueue) { mSession.setQueue(newQueue); mSession.setQueueTitle(title); } }); LocalPlayback playback = new LocalPlayback(this, mMusicProvider); mPlaybackManager = new PlaybackManager(this, getResources(), mMusicProvider, queueManager, playback); // Start a new MediaSession mSession = new MediaSessionCompat(this, "MusicService"); //setSessionToken(mSession.getSessionToken()); mSession.setCallback(mPlaybackManager.getMediaSessionCallback()); mSession.setFlags( MediaSessionCompat.FLAG_HANDLES_MEDIA_BUTTONS | MediaSessionCompat.FLAG_HANDLES_TRANSPORT_CONTROLS); Context context = getApplicationContext(); Intent intent = new Intent(context, MainActivity.class); PendingIntent pi = PendingIntent.getActivity(context, 99, intent, PendingIntent.FLAG_UPDATE_CURRENT); mSession.setSessionActivity(pi); mSessionExtras = new Bundle(); mSession.setExtras(mSessionExtras); mPlaybackManager.updatePlaybackState(null); try { mMediaNotificationManager = new MediaNotificationManager(this); } catch (RemoteException e) { throw new IllegalStateException("Could not create a MediaNotificationManager", e); } VideoCastManager.getInstance().addVideoCastConsumer(mCastConsumer); mMediaRouter = MediaRouter.getInstance(getApplicationContext()); }
From source file:com.android.deskclock.alarms.AlarmNotifications.java
public static void showAlarmNotification(Service service, AlarmInstance instance) { LogUtils.v("Displaying alarm notification for alarm instance: " + instance.mId); Resources resources = service.getResources(); NotificationCompat.Builder notification = new NotificationCompat.Builder(service) .setContentTitle(instance.getLabelOrDefault(service)) .setContentText(AlarmUtils.getFormattedTime(service, instance.getAlarmTime())) .setSmallIcon(R.drawable.stat_notify_alarm).setOngoing(true).setAutoCancel(false) .setDefaults(NotificationCompat.DEFAULT_LIGHTS).setWhen(0) .setCategory(NotificationCompat.CATEGORY_ALARM).setVisibility(NotificationCompat.VISIBILITY_PUBLIC) .setLocalOnly(true);//from w w w.j a v a 2s .com // Setup Snooze Action Intent snoozeIntent = AlarmStateManager.createStateChangeIntent(service, AlarmStateManager.ALARM_SNOOZE_TAG, instance, AlarmInstance.SNOOZE_STATE); snoozeIntent.putExtra(AlarmStateManager.FROM_NOTIFICATION_EXTRA, true); PendingIntent snoozePendingIntent = PendingIntent.getService(service, instance.hashCode(), snoozeIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(R.drawable.ic_snooze_24dp, resources.getString(R.string.alarm_alert_snooze_text), snoozePendingIntent); // Setup Dismiss Action Intent dismissIntent = AlarmStateManager.createStateChangeIntent(service, AlarmStateManager.ALARM_DISMISS_TAG, instance, AlarmInstance.DISMISSED_STATE); dismissIntent.putExtra(AlarmStateManager.FROM_NOTIFICATION_EXTRA, true); PendingIntent dismissPendingIntent = PendingIntent.getService(service, instance.hashCode(), dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); notification.addAction(R.drawable.ic_alarm_off_24dp, resources.getString(R.string.alarm_alert_dismiss_text), dismissPendingIntent); // Setup Content Action Intent contentIntent = AlarmInstance.createIntent(service, AlarmActivity.class, instance.mId); notification.setContentIntent(PendingIntent.getActivity(service, instance.hashCode(), contentIntent, PendingIntent.FLAG_UPDATE_CURRENT)); // Setup fullscreen intent Intent fullScreenIntent = AlarmInstance.createIntent(service, AlarmActivity.class, instance.mId); // set action, so we can be different then content pending intent fullScreenIntent.setAction("fullscreen_activity"); fullScreenIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_USER_ACTION); notification.setFullScreenIntent(PendingIntent.getActivity(service, instance.hashCode(), fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT), true); notification.setPriority(NotificationCompat.PRIORITY_MAX); clearNotification(service, instance); service.startForeground(instance.hashCode(), notification.build()); }
From source file:com.android.mms.transaction.NotificationTransaction.java
public void run() { MmsLog.d(MmsApp.TXN_TAG, "NotificationTransaction: run"); DownloadManager downloadManager = DownloadManager.getInstance(); boolean autoDownload = allowAutoDownload(mContext, mSubId); try {/*from w w w. ja va2s.co m*/ if (LOCAL_LOGV) { Log.v(TAG, "Notification transaction launched: " + this); } // By default, we set status to STATUS_DEFERRED because we // should response MMSC with STATUS_DEFERRED when we cannot // download a MM immediately. int status = STATUS_DEFERRED; // Don't try to download when data is suspended, as it will fail, so defer download if (!autoDownload) { // M: change API for ALPS01889178, use sub id. downloadManager.markState(mUri, DownloadManager.STATE_UNSTARTED, mSubId); sendNotifyRespInd(status); getState().setState(SUCCESS); getState().setContentUri(mUri); notifyObservers(); return; } // M: change API for ALPS01889178, use sub id. downloadManager.markState(mUri, DownloadManager.STATE_DOWNLOADING, mSubId); if (mOpNotificationTransactionExt.run(mIsCancelling, mUri, mContext, getUri(), mContentLocation)) { mTransactionState.setState(TransactionState.SUCCESS); mTransactionState.setContentUri(mUri); mIsCancelling = false; return; } if (LOCAL_LOGV) { Log.v(TAG, "Content-Location: " + mContentLocation); } mPduFile = createPduFile(null, RETRIEVE_RESULT_NAME + mUri.getLastPathSegment()); mPduFile.setWritable(true, false); //Intent intent = new Intent(TransactionService.ACTION_TRANSACION_PROCESSED); //intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId); //intent.putExtra(TransactionBundle.URI, mUri.toString()); Log.d(MmsApp.TXN_TAG, "NotificationTransaction mUri:" + mUri); final Intent intent = new Intent(TransactionService.ACTION_TRANSACION_PROCESSED, mUri, mContext, MmsReceiver.class); intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId); PendingIntent downloadedIntent = PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); SmsManager manager = SmsManager.getSmsManagerForSubscriptionId(mSubId); Log.d(MmsApp.TXN_TAG, "download MMS with param, mContentLocation = " + mContentLocation + ", mUri = " + mUri + ", subId" + mSubId); /// M: Add MmsService configure param @{ Uri pduFileUri = FileProvider.getUriForFile(mContext, MMS_FILE_PROVIDER_AUTHORITIES, mPduFile); manager.downloadMultimediaMessage(mContext, mContentLocation, pduFileUri, MmsConfig.getMmsServiceConfig(), downloadedIntent); /// @} // sendNotifyRespInd(status); // Make sure this thread isn't over the limits in message count. Recycler.getMmsRecycler().deleteOldMessagesInSameThreadAsMessage(mContext, mUri); MmsWidgetProvider.notifyDatasetChanged(mContext); } catch (Throwable t) { getState().setState(FAILED); getState().setContentUri(mUri); notifyObservers(); Log.e(TAG, Log.getStackTraceString(t)); } }
From source file:markson.visuals.sitapp.settingActivity.java
public void notifications() { // get a Calendar object with current time Intent intent = new Intent(getApplicationContext(), ClassesService.class); //intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pi = PendingIntent.getService(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); try {/*from w w w. j a v a 2s. c o m*/ pi.send(); } catch (PendingIntent.CanceledException e) { // the stack trace isn't very helpful here. Just log the exception message. System.out.println("Sending Notification failed "); } /*Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, 07); calendar.set(Calendar.MINUTE, 00); calendar.set(Calendar.SECOND, 00); // add 5 minutes to the calendar object //cal.add(Calendar.SECOND, 10); Log.e("Testing", "Calender Set time:"+calendar.getTime()); //Log.e("Testing", "Intent created"); //intent.putExtra("alarm_message", "O'Doyle Rules!"); // In reality, you would want to have a static variable for the request code instead of 192837 AlarmManager alarm_manager = (AlarmManager)getSystemService(Context.ALARM_SERVICE); alarm_manager.setRepeating(AlarmManager.RTC, calendar.getTimeInMillis(),24*60*60*1000, pi);*/ }
From source file:com.b44t.messenger.MusicPlayerService.java
public void setListeners(RemoteViews view) { PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PREVIOUS), PendingIntent.FLAG_UPDATE_CURRENT); view.setOnClickPendingIntent(R.id.player_previous, pendingIntent); pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_CLOSE), PendingIntent.FLAG_UPDATE_CURRENT); view.setOnClickPendingIntent(R.id.player_close, pendingIntent); pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PAUSE), PendingIntent.FLAG_UPDATE_CURRENT); view.setOnClickPendingIntent(R.id.player_pause, pendingIntent); pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_NEXT), PendingIntent.FLAG_UPDATE_CURRENT); view.setOnClickPendingIntent(R.id.player_next, pendingIntent); pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, new Intent(NOTIFY_PLAY), PendingIntent.FLAG_UPDATE_CURRENT); view.setOnClickPendingIntent(R.id.player_play, pendingIntent); }
From source file:ch.carteggio.provider.sync.NotificationService.java
private void showFailureNotification() { NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); NotificationCompat.Builder notifyBuilder = new NotificationCompat.Builder(this) .setContentTitle("Carteggio network error").setSmallIcon(android.R.drawable.stat_notify_error); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addParentStack(NetworkStatusActivity.class); stackBuilder.addNextIntent(new Intent(this, NetworkStatusActivity.class)); notifyBuilder.setContentIntent(stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)); if (mSendFailure && mReceiveFailure) { notifyBuilder.setContentText("There was a problem while delivering and receiving messages"); } else if (mSendFailure) { notifyBuilder.setContentText("There was a problem while delivering messages"); } else if (mReceiveFailure) { notifyBuilder.setContentText("There was a problem while receiving messages"); }/* w w w . ja v a 2 s.c o m*/ mNotificationManager.notify(ERROR_NOTIFICATION_ID, notifyBuilder.build()); }
From source file:cc.psdev.heywifi.MainService.java
private void showTurnedoffNoti(int type) { if (type == 1 && alreadyNoticed == 0) { NotificationCompat.Builder noti = new NotificationCompat.Builder(this); noti.setSmallIcon(R.drawable.ic_notification); noti.setContentTitle(getResources().getString(R.string.stopnoti_title)); noti.setTicker(getResources().getString(R.string.stopnoti_ticker)); noti.setContentText(getResources().getString(R.string.stopnoti_text)); noti.setOngoing(true);/*from w w w . j av a 2 s .co m*/ Intent notiIntent = new Intent(this, SelectRunServiceActivity.class); notiIntent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); // TODO: pendingIntent PendingIntent pendingIntent = PendingIntent.getActivity(this, 1320001, notiIntent, PendingIntent.FLAG_UPDATE_CURRENT); noti.setContentIntent(pendingIntent); nm.notify(1111, noti.build()); alreadyNoticed = 1; } else if (type == 0) { nm.cancel(1111); alreadyNoticed = 0; } }
From source file:br.com.devfest.norte.wear.HomeListenerService.java
/** * Builds notification for wear based on the data in the Data Item that is passed in. *//*w w w .j ava2 s.c o m*/ private void setupNotification(DataItem dataItem) { LOGD(TAG, "setupNotification(): DataItem=" + dataItem.getUri()); PutDataMapRequest putDataMapRequest = PutDataMapRequest .createFromDataMapItem(DataMapItem.fromDataItem(dataItem)); final DataMap dataMap = putDataMapRequest.getDataMap(); String sessionId = dataMap.getString(KEY_SESSION_ID); String sessionRoom = dataMap.getString(KEY_SESSION_ROOM); String sessionName = dataMap.getString(KEY_SESSION_NAME); String speakers = dataMap.getString(KEY_SPEAKER_NAME); int notificationId = (int) new Date().getTime(); Intent intent = new Intent(ACTION_DISMISS); intent.putExtra(KEY_SESSION_ID, dataMap.getString(KEY_SESSION_ID)); // need to be notified if user dismisses teh notification so we can dismiss the // corresponding notification on teh paired handset. PendingIntent deleteIntent = PendingIntent.getService(this, notificationId, intent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent showCardIntent = showCardIntent(sessionId, sessionRoom, sessionName, speakers, notificationId); NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(getString(R.string.rate_this_session)) .setDeleteIntent(deleteIntent).setContentText(sessionName) .extend(new NotificationCompat.WearableExtender().setDisplayIntent(showCardIntent)); NotificationManagerCompat.from(this).notify(sessionId, NOTIFICATION_ID, builder.build()); }
From source file:com.android.mms.transaction.RetrieveTransaction.java
public void run() { MmsLog.i(MmsApp.TXN_TAG, "RetrieveTransaction: run()"); try {//from w w w .ja va 2 s . com NotificationInd nInd = (NotificationInd) PduPersister.getPduPersister(mContext).load(mUri); if (nInd.getExpiry() < System.currentTimeMillis() / 1000L) { MmsLog.d(MmsApp.TXN_TAG, "The message is expired!"); sendExpiredRes(); // Change the downloading state of the M-Notification.ind. DownloadManager.getInstance().markState(mUri, DownloadManager.STATE_DOWNLOADING); mTransactionState.setState(TransactionState.SUCCESS); mTransactionState.setContentUri(mUri); notifyObservers(); return; } // Change the downloading state of the M-Notification.ind. DownloadManager.getInstance().markState(mUri, DownloadManager.STATE_DOWNLOADING); /// M: For OP009, check if cancel download requested. @{ /* if (MmsConfig.isCancelDownloadEnable() && mIsCancelling) { mTransactionState.setState(TransactionState.SUCCESS); mTransactionState.setContentUri(mUri); if (MmsConfig.isCancelDownloadEnable()) { sMmsFailedNotifyPlugin.popupToast(mContext, IMmsFailedNotifyExt.CANCEL_DOWNLOAD, null); } mIsCancelling = false; final Uri trxnUri = getUri(); sCancelDownloadPlugin.markStateExt(trxnUri, sCancelDownloadPlugin.STATE_COMPLETE); DownloadManager.getInstance().markState(trxnUri, DownloadManager.STATE_UNSTARTED); return; }*/ /// @} if (mOpRetrieveTransactionExt.run(mIsCancelling, mUri, mContext, getUri(), mContentLocation)) { mTransactionState.setState(TransactionState.SUCCESS); mTransactionState.setContentUri(mUri); mIsCancelling = false; return; } mPduFile = createPduFile(null, RETRIEVE_RESULT_NAME + mUri.getLastPathSegment()); mPduFile.setWritable(true, false); //Intent intent = new Intent(TransactionService.ACTION_TRANSACION_PROCESSED); //intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId); //intent.putExtra(TransactionBundle.URI, mUri.toString()); Log.d(MmsApp.TXN_TAG, "RetrieveTransaction mUri:" + mUri); final Intent intent = new Intent(TransactionService.ACTION_TRANSACION_PROCESSED, mUri, mContext, MmsReceiver.class); intent.putExtra(PhoneConstants.SUBSCRIPTION_KEY, mSubId); PendingIntent downloadedIntent = PendingIntent.getBroadcast(mContext, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); SmsManager manager = SmsManager.getSmsManagerForSubscriptionId(mSubId); Log.d(MmsApp.TXN_TAG, "download MMS with param, mContentLocation = " + mContentLocation + ", mUri = " + mUri + ", subId" + mSubId); /// M: Add MmsService configure param @{ Uri pduFileUri = FileProvider.getUriForFile(mContext, MMS_FILE_PROVIDER_AUTHORITIES, mPduFile); manager.downloadMultimediaMessage(mContext, mContentLocation, pduFileUri, MmsConfig.getMmsServiceConfig(), downloadedIntent); /// @} // Make sure this thread isn't over the limits in message count. Recycler.getMmsRecycler().deleteOldMessagesInSameThreadAsMessage(mContext, mUri); /// OP009 MMS Feature: cancel download Mms @{ /* if (MmsConfig.isCancelDownloadEnable()) { sCancelDownloadPlugin.addHttpClient(mContentLocation, mUri); }*/ /// @} // Send ACK to the Proxy-Relay to indicate we have fetched the // MM successfully. // Don't mark the transaction as failed if we failed to send it. // sendAcknowledgeInd(retrieveConf); } catch (Throwable t) { Log.e(TAG, Log.getStackTraceString(t)); mTransactionState.setState(TransactionState.FAILED); mTransactionState.setContentUri(mUri); notifyObservers(); } }
From source file:androidx.navigation.NavDeepLinkBuilder.java
/** * Construct a {@link PendingIntent} to the {@link #setDestination(int) deep link destination}. * <p>/*w w w. j a v a2 s. com*/ * This constructs the entire {@link #createTaskStackBuilder() task stack} needed. * <p> * You must have {@link #setGraph set a NavGraph} and {@link #setDestination set a destination} * before calling this method. * </p> * * @return a PendingIntent constructed with * {@link TaskStackBuilder#getPendingIntent(int, int)} to deep link to the * given destination */ @NonNull public PendingIntent createPendingIntent() { return createTaskStackBuilder().getPendingIntent(mDestId, PendingIntent.FLAG_UPDATE_CURRENT); }