List of usage examples for android.support.v4.app NotificationManagerCompat from
public static NotificationManagerCompat from(Context context)
From source file:com.stasbar.knowyourself.alarms.AlarmNotifications.java
public static void updateAlarmGroupNotification(Context context) { if (!Utils.isNOrLater()) { return;//from w ww.j av a 2s . co m } NotificationManagerCompat nm = NotificationManagerCompat.from(context); if (getActiveNotificationsCount(context, UPCOMING_GROUP_KEY) == 0) { nm.cancel(ALARM_GROUP_NOTIFICATION_ID); return; } NotificationCompat.Builder summaryNotification = new NotificationCompat.Builder(context).setShowWhen(false) .setColor(ContextCompat.getColor(context, R.color.default_background)) .setSmallIcon(R.drawable.stat_notify_alarm).setGroup(UPCOMING_GROUP_KEY).setGroupSummary(true) .setPriority(NotificationCompat.PRIORITY_HIGH).setCategory(NotificationCompat.CATEGORY_ALARM) .setVisibility(NotificationCompat.VISIBILITY_PUBLIC).setLocalOnly(true); nm.notify(ALARM_GROUP_NOTIFICATION_ID, summaryNotification.build()); }
From source file:ti.modules.titanium.android.notificationmanager.NotificationManagerModule.java
@Kroll.method public boolean areNotificationsEnabled() { return NotificationManagerCompat.from(TiApplication.getInstance()).areNotificationsEnabled(); }
From source file:com.example.pyrkesa.shwc.OngoingNotificationListenerService.java
@Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals(PATH_DISMISS)) { NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); notificationManager.cancel(NOTIFICATION_ID); }/*from ww w . jav a 2 s . co m*/ }
From source file:com.sleekcoder.weardemo.NotificationUpdateService.java
private void buildWearableOnlyNotification(String title, String content, int notificationId, boolean withDismissal, Bitmap bitmap) { NotificationCompat.Builder builder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(title).setContentText(content) .setLargeIcon(bitmap);/*from www . j a va 2 s . co m*/ if (withDismissal) { Intent dismissIntent = new Intent(Constants.ACTION_DISMISS); dismissIntent.putExtra(Constants.KEY_NOTIFICATION_ID, Constants.BOTH_ID); PendingIntent pendingIntent = PendingIntent.getService(this, 0, dismissIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setDeleteIntent(pendingIntent); } NotificationCompat.BigTextStyle secondPageStyle = new NotificationCompat.BigTextStyle(); secondPageStyle.setBigContentTitle("Page 2").bigText("This is the second page of the notification"); Notification secondPageNotification = new NotificationCompat.Builder(this).setStyle(secondPageStyle) .build(); Notification twoPageNotification = new NotificationCompat.WearableExtender().addPage(secondPageNotification) .extend(builder).build(); NotificationManagerCompat.from(this).notify(notificationId, twoPageNotification); }
From source file:com.ncode.android.apps.schedo.iowear.PagerActivity.java
@Override public void submit() { // do the submission Intent finishIntent = new Intent(this, FinishActivity.class); try {// w w w .j a v a 2s . c om PutDataRequest dataRequest = buildDataRequest(); if (mGoogleApiClient.isConnected()) { Wearable.DataApi.putDataItem(mGoogleApiClient, dataRequest) .setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { if (!dataItemResult.getStatus().isSuccess()) { Utils.LOGD(TAG, "Failed to send back responses, status: " + dataItemResult.getStatus()); } } }); } else { Log.e(TAG, "submit() Failed to send data to phone since there was no Google API " + "client connectivity"); } } catch (JSONException e) { Log.e(TAG, "Failed to build a json from responses", e); } // remove local notification upon submission NotificationManagerCompat.from(this).cancel(mSessionId, HomeListenerService.NOTIFICATION_ID); // clear persisted local data Utils.clearResponses(this); startActivity(finishIntent); finish(); }
From source file:br.com.devfest.norte.wear.PagerActivity.java
@Override public void submit() { // do the submission Intent finishIntent = new Intent(this, FinishActivity.class); try {/*from www . ja v a 2 s . com*/ PutDataRequest dataRequest = buildDataRequest(); if (mGoogleApiClient.isConnected()) { Wearable.DataApi.putDataItem(mGoogleApiClient, dataRequest) .setResultCallback(new ResultCallback<DataApi.DataItemResult>() { @Override public void onResult(DataApi.DataItemResult dataItemResult) { if (!dataItemResult.getStatus().isSuccess()) { LOGD(TAG, "Failed to send back responses, status: " + dataItemResult.getStatus()); } } }); } else { Log.e(TAG, "submit() Failed to send data to phone since there was no Google API " + "client connectivity"); } } catch (JSONException e) { Log.e(TAG, "Failed to build a json from responses", e); } // remove local notification upon submission NotificationManagerCompat.from(this).cancel(mSessionId, HomeListenerService.NOTIFICATION_ID); // clear persisted local data Utils.clearResponses(this); startActivity(finishIntent); finish(); }
From source file:rp.soi.dmsd.notextingwhilewalking.DetectedActivitiesIntentService.java
public void createNotification(boolean makeHeadsUpNotification) { NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_priority_high_black_24dp).setPriority(Notification.PRIORITY_DEFAULT) .setCategory(Notification.CATEGORY_MESSAGE).setContentTitle("No-Texting-While-Walking") .setContentText("It is hazardous to be texting while walking."); if (makeHeadsUpNotification) { Intent push = new Intent(getApplication(), MainActivity.class); push.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); //push.setClass(this, MainActivity.class); PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, push, PendingIntent.FLAG_CANCEL_CURRENT); notificationBuilder.setContentText("It is hazardous to be texting while walking.") .setFullScreenIntent(fullScreenPendingIntent, true); }/*from www .j av a 2 s . c om*/ Notification notification = notificationBuilder.build(); //---set the sound and lights--- notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_LIGHTS; //---gets an instance of the NotificationManager service--- NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); //---build the notification and issues it // with notification manager--- notificationManager.notify(WEARABLE_NOTIFICATION_ID, notification); }
From source file:ufms.br.com.ufmsapp.gcm.UfmsGcmListenerService.java
private void buildGcmNotificationEvento(String title, String msg, Class mClass, String intentExtraName, String valueId, String disciplina) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); boolean isSoundEnabled = prefs.getBoolean(getResources().getString(R.string.pref_notification_sound), true); NotificationManagerCompat nm = NotificationManagerCompat.from(this); Intent it = new Intent(this, mClass); it.putExtra(intentExtraName, valueId); TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); stackBuilder.addNextIntent(it);//from w w w .j a va 2 s . c om PendingIntent pit = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this); if (isSoundEnabled) { mBuilder.setDefaults(Notification.DEFAULT_ALL); } NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle(); bigTextStyle.setBigContentTitle(title).setSummaryText(disciplina).bigText(msg); mBuilder.setStyle(bigTextStyle); mBuilder.setAutoCancel(true); mBuilder.setContentIntent(pit); mBuilder.setColor(ContextCompat.getColor(this, R.color.accentColor)); mBuilder.setSmallIcon(R.mipmap.ic_launcher_white); mBuilder.setContentTitle(title); mBuilder.setContentText(msg); nm.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.onecase.chatroom.service.DataLayerService.java
private void notify(NotificationData notificationData) { int notificationId = 001; Intent firstPageIntent = new Intent(this, FitnessUI.class); PendingIntent firstPagePendingIntent = PendingIntent.getActivity(this, 0, firstPageIntent, 0); NotificationCompat.Builder firstPageBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(notificationData.title) .setContentText(notificationData.content).setContentIntent(firstPagePendingIntent) .setLocalOnly(true);// w ww . ja va2s .co m Intent secondPageIntent = new Intent(this, MessageListUI.class); PendingIntent secondPagePendingIntent = PendingIntent.getActivity(this, 0, secondPageIntent, PendingIntent.FLAG_UPDATE_CURRENT); Notification secondPageNotification = new NotificationCompat.Builder(this) .extend(new NotificationCompat.WearableExtender().setDisplayIntent(secondPagePendingIntent) .setCustomSizePreset(Notification.WearableExtender.SIZE_MEDIUM)) .build(); Notification notification = new NotificationCompat.WearableExtender().addPage(secondPageNotification) .extend(firstPageBuilder).build(); NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this); notificationManagerCompat.notify(notificationId++, notification); }
From source file:com.sunildhaker.watch.heart.WearActivity.java
public void showNotification() { // Build an intent for an action to view a map Intent mapIntent = new Intent(this, SelectActivity.class); Intent viewIntent = new Intent(this, WearActivity.class); //viewIntent.putExtra(EXTRA_EVENT_ID, eventId); PendingIntent viewPendingIntent = PendingIntent.getActivity(this, 0, viewIntent, 0); // Uri geoUri = Uri.parse("geo:0,0?q=" + Uri.encode(location)); // mapIntent.setData(geoUri); PendingIntent mapPendingIntent = PendingIntent.getActivity(this, 0, mapIntent, 0); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.eureka_blue_fill).setContentTitle("Dummy Notif") .setContentText("Some dummy text here ").setContentIntent(viewPendingIntent) .addAction(R.drawable.eureka_blue_fill, "Get Help", mapPendingIntent); Notification notif = notificationBuilder.build(); // notificationBuilder.notify(); // Get an instance of the NotificationManager service NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this); // Issue the notification with notification manager. notificationManager.notify(5, notif); }