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:com.safecell.HomeScreenActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { // android:background="@drawable/stop_button" // TODO Auto-generated method stub super.onCreate(savedInstanceState); Log.v(TAG, "on create"); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setWindowAnimations(R.anim.null_animation); contextHomeScreenActivity = HomeScreenActivity.this; mManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); profilesRepository = new ProfilesRepository(contextHomeScreenActivity); isgameplay = this.GamplayOnOff(); if (!InformatonUtils.isServiceRunning(this)) { startService();/*from w ww .j av a2 s.c o m*/ } // ServiceHandler.getInstance(this).bindService(); this.initUI(); Log.v(TAG, "Emergencies.Inbound_Details Size:" + Emergencies.Inbound_Details.size()); // Request for Emergency numbers new EmergencyHandler(contextHomeScreenActivity, profilesRepository.getId()).execute(); IsTripPaused(); IsTripSaved(); Log.d(TAG, "Setings = " + getSharedPreferences("SETTINGS", MODE_WORLD_READABLE).getBoolean("isDisabled", false)); sharedPreferences = getSharedPreferences("TRIP", MODE_WORLD_READABLE); this.recentTripLog(); deleteFile(WayPointStore.WAY_POINT_FILE); deleteFile(InterruptionStore.INTERRUPTION_POINT_FILE); // setListAdapter(new recentTripAdapater(HomeScreenActivity.this)); if (isAppTermited()) { deleteLastTempTrip(); Intent mIntent = new Intent(HomeScreenActivity.this, TrackingScreenActivity.class); mIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Log.v("HomeScreenActivity", "AppTerminated"); startActivity(mIntent); finish(); // clearTrackingScreenPref(); } /* * if(!isAppTermited()) { Log.v("SafeCell: Temp data", * "Delete Last Data"); deleteLastTempTrip(); } */ }
From source file:ca.rmen.android.networkmonitor.app.service.NetMonNotification.java
/** * Shows a notification with the given ticker text and content text. The icon is a warning icon, and the notification title is the app name. Tapping on the * notification opens the given activity. *///from www .java 2 s .c om private static void showNotification(Context context, int notificationId, int tickerTextId, int contentTextId, Class<?> activityClass) { NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setSmallIcon(R.drawable.ic_stat_warning); builder.setAutoCancel(true); builder.setTicker(context.getString(tickerTextId)); builder.setContentTitle(context.getString(R.string.app_name)); builder.setContentText(context.getString(contentTextId)); builder.setAutoCancel(false); Uri uri = NetMonPreferences.getInstance(context).getNotificationSoundUri(); builder.setSound(uri); builder.setContentIntent(PendingIntent.getActivity(context, 0, new Intent(context, activityClass), PendingIntent.FLAG_UPDATE_CURRENT)); Notification notification = builder.build(); notification.flags |= Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_ONLY_ALERT_ONCE; notification.ledARGB = 0xFFffff00; notification.ledOnMS = 300; notification.ledOffMS = 2000; NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(notificationId, notification); }
From source file:com.pulp.campaigntracker.gcm.GcmIntentService.java
@SuppressWarnings("unchecked") private void sendNotification(GCM msg) { if (msg != null) { int index = 1; mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); NotificationCompat.BigTextStyle bigText = new NotificationCompat.BigTextStyle(); bigText.bigText(msg.getMessage()); bigText.setBigContentTitle(msg.getTitle()); Uri uri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); mNotificationCount = mAppPref.getInt("Notif_Number_Constant", 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.notification_app_icon).setContentTitle(msg.getTitle()) .setStyle(bigText).setContentText(msg.getMessage()).setSound(uri) .setNumber(mNotificationCount + 1); mAppPref.edit().putInt("Notif_Number_Constant", (mNotificationCount + 1)).commit(); try {/*w w w .j a v a2s. co m*/ if ((ArrayList<UserNotification>) ObjectSerializer .deserialize(mAppPref.getString(ConstantUtils.NOTIFICATION, "")) == null) { notifyList = new ArrayList<UserNotification>(); } else { notifyList = (ArrayList<UserNotification>) ObjectSerializer .deserialize(mAppPref.getString(ConstantUtils.NOTIFICATION, "")); } } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } notification = new UserNotification(); notification.setTitle(msg.getTitle()); notification.setMessage(msg.getMessage()); notification.setNotifyTime(System.currentTimeMillis()); notifyList.add(notification); try { mAppPref.edit().putString(ConstantUtils.NOTIFICATION, ObjectSerializer.serialize(notifyList)) .commit(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent newIntent = null; ConstantUtils.SYNC_INTERVAL = 30 * 60 * 1000; // if (mAppPref.getString(ConstantUtils.USER_ROLE, "") // .equals(LoginData.)) { // newIntent = new Intent(getBaseContext(), // UserMotherActivity.class); // Intent i = new Intent(this, PeriodicService.class); // this.startService(i); // } else { newIntent = new Intent(getBaseContext(), SplashScreen.class); Intent i = new Intent(this, PeriodicService.class); this.startService(i); // } PendingIntent contentIntent = PendingIntent.getActivity(GcmIntentService.this, 0, newIntent, 0); mBuilder.setAutoCancel(true); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(index, mBuilder.build()); Intent intent = new Intent(); intent.setAction("googleCloudMessage"); sendBroadcast(intent); } }
From source file:de.appplant.cordova.plugin.background.ForegroundService.java
public void updateNotification() { Notification n = makeNotification(); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); mNotificationManager.notify(NOTIFICATION_ID, n); }
From source file:com.amazon.cordova.plugin.ADMMessageHandler.java
/** * Creates a notification when app is not running or is not in foreground. It puts the message info into the Intent * extra/*from w ww . j ava 2s .c o m*/ * * @param context * @param extras */ public void createNotification(Context context, Bundle extras) { NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); String appName = getAppName(this); // reuse the intent so that we can combine multiple messages into extra if (notificationIntent == null) { notificationIntent = new Intent(this, ADMHandlerActivity.class); } notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); notificationIntent.putExtra("pushBundle", extras); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); final Builder notificationBuilder = new Notification.Builder(context); notificationBuilder.setSmallIcon(context.getApplicationInfo().icon).setWhen(System.currentTimeMillis()) .setContentIntent(contentIntent); if (this.shouldShowMessageInNotification()) { String message = extras.getString(PushPlugin.MESSAGE); notificationBuilder.setContentText(Html.fromHtml(message).toString()); } else { notificationBuilder.setContentText(this.defaultMessageTextInNotification()); } String title = appName; notificationBuilder.setContentTitle(title).setTicker(title); notificationBuilder.setAutoCancel(true); // Because the ID remains unchanged, the existing notification is updated. notificationManager.notify((String) appName, NOTIFICATION_ID, notificationBuilder.getNotification()); }
From source file:com.upnext.blekit.actions.BLEAction.java
/** * Displays a notification/*from ww w .j a va 2s. c o m*/ * * @param context Android Context, passed from the calling entity * @param title title for the notification * @param msg message and ticker for the notification * @param type action type that will be put as an extra into the result Intent (<code>resultIntent.putExtra("type", type);</code>) * @param notificationIconResId notification icon resource id * @param notificationId an identifier for this notification as in {@link android.app.NotificationManager#notify(int, android.app.Notification)} */ public static void displayNotification(Context context, String title, String msg, String type, int notificationIconResId, int notificationId) { L.d("."); if (BLEKit.getTargetActivityForNotifications() == null) { throw new IllegalArgumentException( "Target activity for notifications is not set. Call BLEKit.getTargetActivityForNotifications() first."); } Notification.Builder builder = new Notification.Builder(context).setContentText(msg).setTicker(msg) .setContentTitle(title).setAutoCancel(true).setSmallIcon(notificationIconResId); Intent resultIntent = new Intent(context, BLEKit.getTargetActivityForNotifications()); resultIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); resultIntent.putExtra("type", type); PendingIntent resultPendingIntent = PendingIntent.getActivity(context, 0, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(notificationId, builder.build()); }
From source file:net.exclaimindustries.geohashdroid.services.WikiService.java
@Override public void onCreate() { super.onCreate(); // WakeLock awaaaaaay! PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "WikiService"); // Also, get the NotificationManager on standby. mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); }
From source file:com.arubadesignweb.app.appoverview.util.GcmIntentService.java
private void sendNotificationSuccess(Bundle extras) { mNotificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, Application.class), 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setDefaults(Notification.DEFAULT_ALL).setSmallIcon(R.drawable.push_icon) .setContentTitle(extras.getString("title")) .setStyle(new NotificationCompat.BigTextStyle().bigText(extras.getString("message"))) .setContentText(extras.getString("message")); mBuilder.setAutoCancel(true);//from w w w. j a v a 2 s . c o m mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); CommonUtilities.markAsDisplayed(extras.getString("message_id")); }
From source file:com.arubadesignweb.app.appoverview.util.GcmIntentService.java
public static void sendLocalNotification(Context context, String title, String message, String message_id) { NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, new Intent(context, Application.class), 0);/*from w w w . j a va 2 s . c o m*/ NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setDefaults(Notification.DEFAULT_ALL).setSmallIcon(R.drawable.push_icon).setContentTitle(title) .setStyle(new NotificationCompat.BigTextStyle().bigText(message)).setContentText(message); mBuilder.setAutoCancel(true); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); CommonUtilities.markAsDisplayed(message_id); }
From source file:com.iniciacomunicacion.devicenotification.DeviceNotification.java
/** * Cancels all notifications/* w w w . jav a2 s . c o m*/ * * @param callbackContext Callback context of the request from Cordova */ public void cancelAll(CallbackContext callbackContext) { NotificationManager notificationManager = (NotificationManager) cordova.getActivity() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancelAll(); }