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.jorge.mobile.com.transportalert.alarm.ServiceAlarm.java
@Override protected void onHandleIntent(Intent intent) { // Do the task here Log.i(TAG, "Service running"); notificationManager = (NotificationManager) getApplicationContext() .getSystemService(Context.NOTIFICATION_SERVICE); Retrofit retrofit = new Retrofit.Builder().baseUrl(getString(R.string.url_tfl_api)) .addConverterFactory(GsonConverterFactory.create()).build(); TaskService taskService = retrofit.create(TaskService.class); Call<List<StatusLine>> call = taskService.login(getString(R.string.app_id), getString(R.string.app_key)); call.enqueue(this); }
From source file:app.com.ark.android.sunshine.GcmBroadcastReceiver.java
private void sendNotification(Context context, String msg) { mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, MainActivity.class), 0);//from w w w .j a va 2 s. c om NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.art_storm).setContentTitle("Weather Alert!") .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg) .setPriority(NotificationCompat.PRIORITY_HIGH); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }
From source file:com.arellomobile.android.push.PushGCMIntentService.java
private static void generateNotification(Context context, Intent intent, Handler handler) { Bundle extras = intent.getExtras();/*from ww w .j av a 2 s . com*/ if (extras == null) { return; } extras.putBoolean("foregroud", GeneralUtils.isAppOnForeground(context)); String title = (String) extras.get("title"); String link = (String) extras.get("l"); // empty message with no data Intent notifyIntent; if (link != null) { // we want main app class to be launched notifyIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(link)); notifyIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } else { notifyIntent = new Intent(context, PushHandlerActivity.class); notifyIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); // pass all bundle notifyIntent.putExtra("pushBundle", extras); } // first string will appear on the status bar once when message is added CharSequence appName = context.getPackageManager().getApplicationLabel(context.getApplicationInfo()); if (null == appName) { appName = ""; } NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationFactory notificationFactory; //is this banner notification? String bannerUrl = (String) extras.get("b"); //also check that notification layout has been placed in layout folder int layoutId = context.getResources().getIdentifier(BannerNotificationFactory.sNotificationLayout, "layout", context.getPackageName()); if (layoutId != 0 && bannerUrl != null) { notificationFactory = new BannerNotificationFactory(context, extras, appName.toString(), title, PushManager.sSoundType, PushManager.sVibrateType); } else { notificationFactory = new SimpleNotificationFactory(context, extras, appName.toString(), title, PushManager.sSoundType, PushManager.sVibrateType); } notificationFactory.generateNotification(); notificationFactory.addSoundAndVibrate(); notificationFactory.addCancel(); Notification notification = notificationFactory.getNotification(); notification.contentIntent = PendingIntent.getActivity(context, 0, notifyIntent, PendingIntent.FLAG_UPDATE_CURRENT); if (mSimpleNotification) { manager.notify(PushManager.MESSAGE_ID, notification); } else { manager.notify(PushManager.MESSAGE_ID++, notification); } generateBroadcast(context, extras); }
From source file:com.makotosan.vimeodroid.TransferService.java
@Override public void onCreate() { super.onCreate(); String svcName = Context.NOTIFICATION_SERVICE; notificationManager = (NotificationManager) getSystemService(svcName); }
From source file:bhtech.com.cabbytaxi.services.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./*from w w w. ja va2 s.c o m*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, FindTaxiController.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("message", message); 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.easyauth.EasyAuth.GCMIntentService.java
private void sendNotification(Bundle extras) { String type = extras.getString("type"); if (type.equals(Constants.EASYAUTH_LOGIN)) { String token = extras.getString("token"); String username = extras.getString("username"); if (token.isEmpty()) { Log.e(TAG, "Empty token received"); }//w ww . j av a 2 s . c o m if (username.isEmpty()) { Log.e(TAG, "Empty username received"); } 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.ic_launcher).setContentTitle("EasyAuth Notification") .setStyle(new NotificationCompat.BigTextStyle().bigText("EasyAuth Login Performed")) .setContentText("EasyAuth Login Performed by " + username); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); JSONObject json = new JSONObject(); try { json.put("token", token); json.put("username", username); } catch (JSONException e) { e.printStackTrace(); } new AsyncHttpTask(this.getApplicationContext()).execute("ip", json.toString()); } else if (type.equals(Constants.EASYAUTH_TOTP_SECRET)) { String username = extras.getString("username"); String secret = extras.getString("secret"); if (secret.isEmpty()) { Log.e(TAG, "Empty secret received"); } if (username.isEmpty()) { Log.e(TAG, "Empty username received"); } SharedPreferences prefs = getSharedPreferences(Constants.EASYAUTH_PREFERENCES_KEY, Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString(Constants.EASYAUTH_TOTP_SECRET_KEY, secret); editor.putString(Constants.EASYAUTH_USERNAME_KEY, username); editor.commit(); } }
From source file:com.maass.android.imgur_uploader.ImgurUpload.java
@Override public void onCreate() { super.onCreate(); mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); }
From source file:assistance.shopping.msc.assistant.support.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message shoppingBroadcastDescription received. */// w w w . j a va2 s .c o m private void sendNotification(String messageBody) { Intent intent = new Intent(this, LoginActivity.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("FCM Message") .setContentText(messageBody).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:ca.rmen.android.networkmonitor.app.service.NetMonNotification.java
static void dismissNotifications(Context context) { Log.v(TAG, "dismissNotification"); context.unregisterReceiver(sDisableBroadcastReceiver); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(NOTIFICATION_ID_ONGOING); notificationManager.cancel(NOTIFICATION_ID_FAILED_EMAIL); notificationManager.cancel(NOTIFICATION_ID_FAILED_TEST); }
From source file:com.quicklookbusy.narwhalNotifier.NarwhalNotifierReceiver.java
/** * Called by the AlarmManager. Checks if the user has any unread messages * // ww w.j a v a 2 s . c om * @param context * Context of the app * @param i * Intent of the caller */ @Override public void onReceive(Context context, Intent i) { log("Alarm went off!"); String ns = Context.NOTIFICATION_SERVICE; notificationManager = (NotificationManager) context.getSystemService(ns); settings = context.getSharedPreferences(NarwhalNotifier.PREFS_NAME, 0); settingsEditor = settings.edit(); /* * runService = true; RedditHitter hitter = new RedditHitter(); * hitter.start(); */ log("checkMessages is " + settings.getBoolean("checkMessages", false)); if (settings.getBoolean("checkMessages", false)) { checkMessages(context, false); } log("checkModmail is " + settings.getBoolean("checkModmail", false)); if (settings.getBoolean("checkModmail", false)) { checkMessages(context, true); } log("checkModqueue is " + settings.getBoolean("checkModqueue", false)); if (settings.getBoolean("checkModqueue", false)) { checkModqueue(context); } }