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:air.com.snagfilms.cast.chromecast.notifications.VideoCastNotificationService.java
/** * Removes the existing notification. */ private void removeNotification() { ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).cancel(NOTIFICATION_ID); }
From source file:com.amazon.cordova.plugin.ADMMessageHandler.java
public static void cancelNotification(Context context) { NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.cancel((String) getAppName(context), NOTIFICATION_ID); }
From source file:yulei.android.client.AndroidMobilePushApp.java
private String getMessage(int numOfMissedMessages) { String message = ""; String linesOfMessageCount = getString(R.string.lines_of_message_count); if (numOfMissedMessages > 0) { String plural = numOfMissedMessages > 1 ? "s" : ""; Log.i("onResume", "missed " + numOfMissedMessages + " message" + plural); tView.append("You missed " + numOfMissedMessages + " message" + plural + ". Your most recent was:\n"); for (int i = 0; i < savedValues.getInt(linesOfMessageCount, 0); i++) { String line = "***" + savedValues.getString("MessageLine" + i, "") + "&&&&"; message += (line + "\n"); }//from ww w .j a v a 2s. com NotificationManager mNotification = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotification.cancel(R.string.notification_number); SharedPreferences.Editor editor = savedValues.edit(); editor.putInt(this.numOfMissedMessages, 0); editor.putInt(linesOfMessageCount, 0); editor.commit(); } else { Log.i("onResume", "no missed messages"); Intent intent = getIntent(); if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null) { String realData = extras.getString("default"); // message += "___" +realData +"___"; if (realData != null && realData.length() > 2) { //addMarker(decodeJSONforLat(realData),decodeJSONforLon(realData)); if (realData.length() > 2) { Log.e("here", realData); try { Toast toast = Toast.makeText(getApplicationContext(), decodeJSONforName(realData) + decodeJSONforTime(realData), Toast.LENGTH_SHORT); toast.show(); Log.e("heres", "sssss"); //addMarker(decodeJSONforLat(realData),decodeJSONforLon(realData)); addMarker(decodeJSONforLat(realData), decodeJSONforLon(realData), decodeJSONforName(realData), decodeJSONforSentiment(realData), decodeJSONforScore(realData)); message = "\n" + decodeJSONforName(realData) + "\n" + decodeJSONforContent(realData) + "\n"; addHeatMap(decodeJSONforLat(realData), decodeJSONforLon(realData)); //addMarker((Double)decodeObj.get("latitute"),(Double)decodeObj.get("longitude"),(String)decodeObj.get("time"),(String)decodeObj.get("userName")); } catch (Exception e) { Log.e("exception", "Exception throwed"); } } } } } } message += "\n"; return message; }
From source file:org.lol.reddit.receivers.NewMessageChecker.java
private static void createNotification(String title, String text, Context context) { final NotificationCompat.Builder notification = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.icon_inv).setContentTitle(title).setContentText(text).setAutoCancel(true); final Intent intent = new Intent(context, InboxListingActivity.class); notification.setContentIntent(PendingIntent.getActivity(context, 0, intent, 0)); final NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(0, notification.getNotification()); }
From source file:ca.rmen.android.poetassistant.PoemAudioExport.java
private void notifyPoemAudioReady() { Log.v(TAG, "notifyPoemAudioReady"); cancelNotifications();//w w w.j a va2s .c om PendingIntent shareIntent = getFileShareIntent(); Notification notification = new NotificationCompat.Builder(mContext).setAutoCancel(true) .setContentIntent(shareIntent) .setContentTitle(mContext.getString(R.string.share_poem_audio_ready_notification_title)) .setContentText(mContext.getString(R.string.share_poem_audio_ready_notification_message)) .setSmallIcon(Share.getNotificationIcon()) .addAction(Share.getShareIconId(), mContext.getString(R.string.share), shareIntent).build(); NotificationManager notificationManager = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(EXPORT_FINISH_NOTIFICATION_ID, notification); }
From source file:android.romstats.ReportingService.java
private void promptUser() { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Intent mainActivity = new Intent(getApplicationContext(), AnonymousStats.class); PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, mainActivity, 0); Notification notification = new NotificationCompat.Builder(getBaseContext()) .setSmallIcon(R.drawable.ic_launcher).setTicker(getString(R.string.notification_ticker)) .setContentTitle(getString(R.string.notification_title)) .setContentText(getString(R.string.notification_desc)).setWhen(System.currentTimeMillis()) .setContentIntent(pendingIntent).setAutoCancel(true).build(); nm.notify(Utilities.NOTIFICATION_ID, notification); }
From source file:biz.bokhorst.bpt.BPTService.java
@Override public IBinder onBind(Intent intent) { // Start foreground service startForeground(1, getNotification(getString(R.string.Running))); // Instantiate helpers locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); databaseHelper = new DatabaseHelper(this); preferences = PreferenceManager.getDefaultSharedPreferences(this); PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); taskHandler = new Handler(); wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "BPT"); notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); Intent alarmIntent = new Intent("BPT_ALARM"); pendingAlarmIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); alarmReceiver = new BPTAlarmReceiver(); registerReceiver(alarmReceiver, new IntentFilter("BPT_ALARM")); bound = true;/*from w w w .j a va 2s . co m*/ return serverMessenger.getBinder(); }
From source file:ru.appsm.inapphelp.IAHHelpDesk.java
/** * * Handle push notification. Cordova.//from w ww. j av a 2 s . c om * * @param data * @param context */ public static void BuildNotificationForDataWithContext(JSONObject data, Context context) { Log.i(TAG, "Create notifications"); if (data != null && data.has("secretkey") && data.has("userid") && data.has("appkey") && data.has("appid") && data.has("email") && data.has("message") && data.has("title") && data.has("notId") && data.has("msgId")) { try { int notId = 1; try { notId = data.getInt("notId"); } catch (JSONException e) { notId = 1; } mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(context, IssueDetailActivity.class); notificationIntent.putExtra("fromPush", true); notificationIntent.putExtra("userid", data.getString("userid")); notificationIntent.putExtra("appid", data.getString("appid")); notificationIntent.putExtra("appkey", data.getString("appkey")); notificationIntent.putExtra("secretkey", data.getString("secretkey")); notificationIntent.putExtra("email", data.getString("email")); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(getApplicationIcon(context)).setContentTitle(data.getString("title")) .setContentText(data.getString("message")).setAutoCancel(true) .setContentIntent(contentIntent); if (data.getString("sound").equals("default")) { mBuilder.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS); } mNotificationManager.notify(notId, mBuilder.build()); } catch (JSONException e) { Log.i(TAG, "Fail to parse push data"); } } else { Log.i(TAG, "Empty or wrong push data"); } }
From source file:com.nbempire.dentalnavarra.component.service.RemembersService.java
private void showNotification(String title, String text, Remember remember) { Log.d(TAG, "Building notification..."); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification).setContentTitle(title).setContentText(text) .setAutoCancel(true);/*from w w w. j a v a 2s . c o m*/ // Creates an explicit intent for an Activity in your app Intent resultIntent = new Intent(this, DentalNavarraActivity.class); if (remember != null) { Log.i(TAG, "Adding extra parameter to notification result intent, message: " + remember.getMessage()); resultIntent.putExtra(NOTIFICATION_INTENT_PARAMETER_MESSAGE, remember.getMessage()); Log.i(TAG, "Adding extra parameter to notification result intent, meetingDate: " + remember.getMeetingDate()); resultIntent.putExtra(NOTIFICATION_INTENT_PARAMETER_MEETING_DATE, remember.getMeetingDate()); Log.i(TAG, "Adding extra parameter to notification result intent, treatments: " + remember.getTreatments()); resultIntent.putExtra(NOTIFICATION_INTENT_PARAMETER_TREATMENTS, remember.getTreatments()); } // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(DentalNavarraActivity.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); Notification notification = mBuilder.build(); notification.defaults |= Notification.DEFAULT_ALL; NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. // TODO : Functionality : Should I unhard-code this ID? mNotificationManager.notify(44, notification); Log.d(TAG, "Notification added to status bar: " + text); }