List of usage examples for android.content Context NOTIFICATION_SERVICE
String NOTIFICATION_SERVICE
To view the source code for android.content Context NOTIFICATION_SERVICE.
Click Source Link
From source file:app.helloworld.ruichen.nicta.helloworld.GcmIntentService.java
private void sendNotification(String msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); Intent in = new Intent(this, MainActivity.class); if (passExtra != null && passExtra.containsKey("latitude")) { in.putExtra("latitude", passExtra.get("latitude").toString()); in.putExtra("longtitude", passExtra.get("longtitude").toString()); }/*w ww . j av a2s .com*/ PendingIntent contentIntent = PendingIntent.getActivity(this, 0, in, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.logo_nicta_org_nobg) .setContentTitle("Evacuation Notification No." + (notificationCounter++)) .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.flowzr.budget.holo.export.flowzr.FlowzrSyncTask.java
protected Object work(Context context, DatabaseAdapter dba, String... params) throws ImportExportException { AccountManager accountManager = AccountManager.get(context); android.accounts.Account[] accounts = accountManager.getAccountsByType("com.google"); String accountName = MyPreferences.getFlowzrAccount(context); if (accountName == null) { NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(context, FlowzrSyncActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT); Builder mNotifyBuilder = new NotificationCompat.Builder(context); mNotifyBuilder.setContentIntent(contentIntent).setSmallIcon(R.drawable.icon) .setWhen(System.currentTimeMillis()).setAutoCancel(true) .setContentTitle(context.getString(R.string.flowzr_sync)) .setContentText(context.getString(R.string.flowzr_choose_account)); nm.notify(0, mNotifyBuilder.build()); Log.i("Financisto", "account name is null"); throw new ImportExportException(R.string.flowzr_choose_account); }// w w w . ja va 2 s .co m Account useCredential = null; for (int i = 0; i < accounts.length; i++) { if (accountName.equals(((android.accounts.Account) accounts[i]).name)) { useCredential = accounts[i]; } } accountManager.getAuthToken(useCredential, "ah", false, new GetAuthTokenCallback(), null); return null; }
From source file:be.ehb.fallwear.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from w w w . j ava2s . c o m */ private void sendNotification(String message) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_ic_notification).setContentTitle("GCM Message") .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.example.week04.GcmIntentService.java
private void sendNotification(String msg) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, MainActivity.class), 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.hummingbird_icon_small).setAutoCancel(true) .setVibrate(new long[] { 0, 500, 200, 500 }).setContentTitle("Hummingbird") .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:kaist.cs492c_2015.washerbrowser.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w w w .ja v a2 s .co m*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_ic_notification).setContentTitle("Find available washer") .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }).setSmallIcon(R.drawable.washer_green) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); launchPopupActivity(this, message); }
From source file:br.ufc.quixada.dsdm.myapplicationtestemulttabs.googleGCM.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from ww w.j a v a 2s. co m*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, MainActivityTabMensagens.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.mensageiro_icon).setContentTitle("MENSSAGEIRO").setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.qurater.pivotal.gcm.GcmIntentServiceV2.java
@SuppressWarnings("unused") private void sendNotification(Bundle extras) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); String msg = ""; String title = ""; String type = extras.getString("type"); String id = extras.getString("id"); String notificationType = "QUESTION"; int notificationId = Integer.valueOf(id); if ("0".equals(type)) { String question = extras.getString("question"); question = (question == null) ? "" : question; question = StringEscapeUtils.unescapeHtml(question); String from = extras.getString("who"); msg = question;//from www .j a v a2 s. c o m title = from + " needs your help."; notificationType = "QUESTION"; } if ("1".equals(type)) { String answer = extras.getString("answer"); answer = (answer == null) ? "" : answer; answer = StringEscapeUtils.unescapeHtml(answer); String from = extras.getString("who"); msg = answer; title = from + "'s new answer to your request."; notificationType = "ANSWER"; } if ("2".equals(type)) { String answer = extras.getString("answer"); answer = (answer == null) ? "" : answer; answer = StringEscapeUtils.unescapeHtml(answer); String from = extras.getString("who"); msg = answer; title = from + " answered a question you follow."; notificationType = "FOLLOW_QUESTION"; } if ("3".equals(type)) { String question = extras.getString("question"); question = (question == null) ? "" : question; question = StringEscapeUtils.unescapeHtml(question); String from = extras.getString("who"); msg = question; title = from + " refered a question."; notificationType = "SHARE"; notificationId = NOTIFICATION_SHARE_ID; } try { } catch (Exception e) { e.printStackTrace(); } }
From source file:com.hybris.mobile.lib.commerce.sync.CatalogSyncAdapter.java
public CatalogSyncAdapter(Context context, boolean autoInitialize, ContentServiceHelper contentServiceHelper) { super(context, autoInitialize); mContentServiceHelper = contentServiceHelper; // Notification mNotifyManager = (NotificationManager) getContext().getSystemService(Context.NOTIFICATION_SERVICE); Notification.Builder builder = new Notification.Builder(getContext()); builder.setContentTitle(getContext().getString(R.string.sync_notification_title)) .setContentText(getContext().getString(R.string.sync_notification_description)) .setSmallIcon(R.drawable.ic_provider); builder.setProgress(0, 0, true);/*from ww w .j a v a 2 s . c o m*/ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { mNotification = builder.build(); } else { mNotification = builder.getNotification(); } // Authority & Account AUTHORITY = contentServiceHelper.getConfiguration().getCatalogAuthority(); }
From source file:asia.covisoft.goom.gcm.GoOmUserGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.// w ww. j a va2 s . c o m */ private void sendNotification(String message, Driverconfirm response) { Intent intent = new Intent(this, HistoryDetailsActivity.class); trandingId = response.getTradingid(); intent.putExtra(Extras.TRADING_ID, trandingId); intent.putExtra(Extras.HISTORY_STATE, false); if (response.getValue().equals("tip")) { intent.putExtra(Extras.REQUEST_TIP, true); intent.putExtra(Extras.MAX_TIP, response.getMaxsuggest()); intent.putExtra(Extras.MIN_TIP, response.getMinsuggest()); cancelTip(); } intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_ic_notification).setContentTitle(getString(R.string.app_name_full)) .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.eyc.statusBarNotification.StatusBarNotification.java
/** * Displays status bar notification/* w ww. j a va 2 s . co m*/ * * @param tag Notification tag. * @param contentTitle Notification title * @param contentText Notification text * */ public void showNotification(CharSequence tag, CharSequence contentTitle, CharSequence contentText, int flag) { String ns = Context.NOTIFICATION_SERVICE; context = cordova.getActivity().getApplicationContext(); mNotificationManager = (NotificationManager) context.getSystemService(ns); Notification noti = StatusNotificationIntent.buildNotification(context, tag, contentTitle, contentText, flag); mNotificationManager.notify(tag.hashCode(), noti); }