List of usage examples for android.app Notification Notification
public Notification()
From source file:com.ucmap.dingdinghelper.services.DingDingHelperAccessibilityService.java
private void increasePriority() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { Notification.Builder mBuilder = new Notification.Builder(this); mBuilder.setSmallIcon(R.mipmap.ic_launcher); startForeground(NOTIFICATION_ID, mBuilder.build()); InnerService.startInnerService(this); } else {// w w w . jav a 2 s . c o m startForeground(NOTIFICATION_ID, new Notification()); } }
From source file:com.sdk.download.providers.downloads.DownloadNotification.java
private void updateCompletedNotification(Collection<DownloadInfo> downloads) { for (DownloadInfo download : downloads) { if (!isCompleteAndVisible(download)) { continue; }//from w w w.j a va2 s. c o m // Add the notifications Notification n = new Notification(); n.icon = android.R.drawable.stat_sys_download_done; n.flags |= Notification.FLAG_AUTO_CANCEL; long id = download.mId; String title = download.mTitle; if (title == null || title.length() == 0) { title = mContext.getResources().getString(R.string.zuimeia_sdk_download_download_unknown_title); } Uri contentUri = ContentUris.withAppendedId(Downloads.getAllDownloadsContentURI(mContext), id); String caption; Intent intent; if (Downloads.isStatusError(download.mStatus)) { caption = mContext.getResources() .getString(R.string.zuimeia_sdk_download_notification_download_failed); intent = new Intent(Constants.ACTION_LIST); } else { caption = mContext.getResources() .getString(R.string.zuimeia_sdk_download_notification_download_complete); if (download.mDestination == Downloads.DESTINATION_EXTERNAL) { intent = new Intent(Constants.ACTION_OPEN); } else { intent = new Intent(Constants.ACTION_LIST); } } intent.setClassName(mContext.getPackageName(), DownloadReceiver.class.getName()); intent.setData(contentUri); n.when = download.mLastMod; n.setLatestEventInfo(mContext, title, caption, PendingIntent.getBroadcast(mContext, 0, intent, 0)); intent = new Intent(Constants.ACTION_HIDE); intent.setClassName(mContext.getPackageName(), DownloadReceiver.class.getName()); intent.setData(contentUri); // n.deleteIntent = PendingIntent.getBroadcast(mContext, 0, intent, // 0); //notification?? mSystemFacade.postNotification(download.mId, n); } }
From source file:com.webkey.Ipc.java
public void notiyShow(Context pContext, String message) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(pContext); if (!prefs.getBoolean("statusbar", true)) { notiyDestroy(pContext);//from w ww.j a v a2s . c o m return; } Notification notification; // Log.d("Webkey","START_notify"); if (manager == null) manager = (NotificationManager) pContext.getSystemService(Context.NOTIFICATION_SERVICE); notification = new Notification(); notification.flags |= Notification.FLAG_ONGOING_EVENT; notification.icon = R.drawable.icon; //notification.tickerText = "Service is running"; notification.when = System.currentTimeMillis(); //Intent notificationIntent = new Intent(); //PendingIntent contentIntent = PendingIntent.getActivity(pContext, 0, notificationIntent, 0); //notification.setLatestEventInfo(pContext, "Webkey", "NotificationContent", contentIntent); Intent notifyIntent = new Intent(pContext, Webkey.class); notification.setLatestEventInfo(pContext, "Webkey", message, PendingIntent.getActivity(pContext, 0, notifyIntent, 0)); manager.notify(1, notification); }
From source file:com.amazonaws.mobileconnectors.pinpoint.targeting.notification.NotificationClient.java
private Notification createLegacyNotification(final int iconResId, final String title, final String contentText, final PendingIntent contentIntent) { final Notification notification = new Notification(); notification.icon = iconResId;//from ww w. ja va2 s . c om notification.setLatestEventInfo(this.pinpointContext.getApplicationContext(), title, contentText, contentIntent); notification.contentIntent = contentIntent; return notification; }
From source file:com.hollandhaptics.babyapp.BabyService.java
/** * @brief Lets the LED indicator flash.//from w w w .j a v a 2 s. co m */ private void FlashLED() { NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notif = new Notification(); notif.ledARGB = 0xFF0000ff; notif.flags = Notification.FLAG_SHOW_LIGHTS; notif.ledOnMS = 100; notif.ledOffMS = 900; nm.notify(0, notif); }
From source file:org.sipdroid.sipua.ui.Receiver.java
public static void onText(int type, String text, int mInCallResId, long base) { if (mSipdroidEngine != null && type == REGISTER_NOTIFICATION + mSipdroidEngine.pref) { cache_text = text;/*from www . j a v a 2 s . c om*/ cache_res = mInCallResId; } if (type >= REGISTER_NOTIFICATION && mInCallResId == R.drawable.sym_presence_available && !PreferenceManager.getDefaultSharedPreferences(Receiver.mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_REGISTRATION, org.sipdroid.sipua.ui.Settings.DEFAULT_REGISTRATION)) text = null; NotificationManager mNotificationMgr = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); if (text != null) { Notification notification = new Notification(); NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext); notification.icon = mInCallResId; if (type == MISSED_CALL_NOTIFICATION) { notification.flags |= Notification.FLAG_AUTO_CANCEL; //TODO /*notification.setLatestEventInfo(mContext, text, mContext.getString(R.string.app_name), PendingIntent.getActivity(mContext, 0, createCallLogIntent(), 0)); if (PreferenceManager.getDefaultSharedPreferences(Receiver.mContext).getBoolean(org.sipdroid.sipua.ui.Settings.PREF_NOTIFY, org.sipdroid.sipua.ui.Settings.DEFAULT_NOTIFY)) { notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0xff0000ff; blue notification.ledOnMS = 125; notification.ledOffMS = 2875; }*/ } else { switch (type) { case MWI_NOTIFICATION: notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.contentIntent = PendingIntent.getActivity(mContext, 0, createMWIIntent(), 0); notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0xff00ff00; /* green */ notification.ledOnMS = 125; notification.ledOffMS = 2875; break; case AUTO_ANSWER_NOTIFICATION: notification.contentIntent = PendingIntent.getActivity(mContext, 0, createIntent(AutoAnswer.class), 0); break; default: if (type >= REGISTER_NOTIFICATION && mSipdroidEngine != null && type != REGISTER_NOTIFICATION + mSipdroidEngine.pref && mInCallResId == R.drawable.sym_presence_available) { int key = type - REGISTER_NOTIFICATION; Intent in = createIntent(ChangeAccount.class); in.setAction(Long.toString(type)); in.putExtra(ChangeAccount.ChangeAccountKey, key); in.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); notification.contentIntent = PendingIntent.getActivity(mContext, key, in, PendingIntent.FLAG_UPDATE_CURRENT); } else notification.contentIntent = PendingIntent.getActivity(mContext, 0, createIntent(Sipdroid.class), 0); if (mInCallResId == R.drawable.sym_presence_away) { notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0xffff0000; /* red */ notification.ledOnMS = 125; notification.ledOffMS = 2875; } notification.flags |= Notification.FLAG_ONGOING_EVENT; break; } RemoteViews contentView = new RemoteViews(mContext.getPackageName(), R.layout.ongoing_call_notification); contentView.setImageViewResource(R.id.icon, notification.icon); if (base != 0) { contentView.setChronometer(R.id.text1, base, text + " (%s)", true); } else if (type >= REGISTER_NOTIFICATION) { if (PreferenceManager.getDefaultSharedPreferences(mContext).getBoolean( org.sipdroid.sipua.ui.Settings.PREF_POS, org.sipdroid.sipua.ui.Settings.DEFAULT_POS)) contentView.setTextViewText(R.id.text2, text + "/" + mContext.getString(R.string.settings_pos3)); else contentView.setTextViewText(R.id.text2, text); if (mSipdroidEngine != null) contentView.setTextViewText(R.id.text1, mSipdroidEngine.user_profiles[type - REGISTER_NOTIFICATION].username + "@" + mSipdroidEngine.user_profiles[type - REGISTER_NOTIFICATION].realm_orig); } else contentView.setTextViewText(R.id.text1, text); notification.contentView = contentView; } mNotificationMgr.notify(type, notification); } else { mNotificationMgr.cancel(type); } if (type != AUTO_ANSWER_NOTIFICATION) updateAutoAnswer(); if (mSipdroidEngine != null && type >= REGISTER_NOTIFICATION && type != REGISTER_NOTIFICATION + mSipdroidEngine.pref) onText(REGISTER_NOTIFICATION + mSipdroidEngine.pref, cache_text, cache_res, 0); }
From source file:com.umaps.gpslogger.GpsLoggingService.java
/** * Resets the form, resets file name if required, reobtains preferences */// ww w. j av a2 s. c om protected void StartLogging() { Log.d(TAG, "."); if (Session.isStarted()) { Log.d(TAG, "Session already started, ignoring"); return; } try { startForeground(NOTIFICATION_ID, new Notification()); } catch (Exception ex) { Log.e(TAG, "Could not start GPSLoggingService in foreground. ", ex); } Session.setStarted(true); GetPreferences(); //ShowNotification(); NotifyClientStarted(); //StartPassiveManager(); StartGpsManager(); RequestActivityRecognitionUpdates(); }
From source file:ch.nexuscomputing.android.osciprimeics.OsciPrimeService.java
/** switch state to idle **/ private void terminateAndClean() { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); sNotification = new Notification(); nm.notify(NOTIFICATION_ID, sNotification); mState = IDLE;// ww w .jav a2s. co m status(); }
From source file:com.geotrackin.gpslogger.GpsLoggingService.java
/** * Resets the form, resets file name if required, reobtains preferences *//*from ww w .jav a2s . c om*/ protected void StartLogging() { tracer.debug("."); Session.setAddNewTrackSegment(true); if (Session.isStarted()) { tracer.debug("Session already started, ignoring"); return; } try { tracer.info("Starting GpsLoggingService in foreground"); startForeground(NOTIFICATION_ID, new Notification()); } catch (Exception ex) { tracer.error("Could not start GPSLoggingService in foreground. ", ex); } Session.setStarted(true); GetPreferences(); ShowNotification(); ResetCurrentFileName(true); NotifyClientStarted(); StartPassiveManager(); StartGpsManager(); }
From source file:org.ozonecity.gpslogger2.GpsLoggingService.java
/** * Resets the form, resets file name if required, reobtains preferences *//*from w w w . ja v a 2 s. co m*/ protected void StartLogging() { tracer.debug("."); Session.setAddNewTrackSegment(true); if (Session.isStarted()) { tracer.debug("Session already started, ignoring"); return; } try { startForeground(NOTIFICATION_ID, new Notification()); } catch (Exception ex) { tracer.error("Could not start GPSLoggingService in foreground. ", ex); } Session.setStarted(true); GetPreferences(); ShowNotification(); SetupAutoSendTimers(); ResetCurrentFileName(true); NotifyClientStarted(); StartPassiveManager(); StartGpsManager(); RequestActivityRecognitionUpdates(); }