List of usage examples for android.app Notification Notification
public Notification()
From source file:com.mendhak.gpslogger.GpsLoggingService.java
/** * Resets the form, resets file name if required, reobtains preferences */// www. j av a2s. c om protected void startLogging() { LOG.debug("."); Session.setAddNewTrackSegment(true); try { startForeground(NOTIFICATION_ID, new Notification()); } catch (Exception ex) { LOG.error("Could not start GPSLoggingService in foreground. ", ex); } Session.setStarted(true); resetAutoSendTimersIfNecessary(); showNotification(); setupAutoSendTimers(); resetCurrentFileName(true); notifyClientStarted(); startPassiveManager(); startGpsManager(); requestActivityRecognitionUpdates(); }
From source file:com.mjhram.geodata.GpsLoggingService.java
/** * Resets the form, resets file name if required, reobtains preferences *//*w w w.j a v a 2 s. com*/ protected void StartLogging() { tracer.debug("."); Session.setAddNewTrackSegment(true); if (Session.isStarted()) { ShowNotification();//MJH 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); //ResetAutoSendTimersIfNecessary(); ShowNotification(); //SetupAutoSendTimers(); ResetCurrentFileName(true); NotifyClientStarted(); StartPassiveManager(); StartGpsManager(); RequestActivityRecognitionUpdates(); }
From source file:com.crearo.gpslogger.GpsLoggingService.java
/** * Resets the form, resets file name if required, reobtains preferences *//*from w w w .j a v a2 s. com*/ protected void startLogging() { LOG.debug("."); Session.setAddNewTrackSegment(true); if (Session.isStarted()) { LOG.debug("Session already started, ignoring"); return; } try { startForeground(NOTIFICATION_ID, new Notification()); } catch (Exception ex) { LOG.error("Could not start GPSLoggingService in foreground. ", ex); } Session.setStarted(true); resetAutoSendTimersIfNecessary(); showNotification(); setupAutoSendTimers(); resetCurrentFileName(true); notifyClientStarted(); startPassiveManager(); startGpsManager(); requestActivityRecognitionUpdates(); }
From source file:com.raddapp.radika.raddappv001.GpsLoggingService.java
/** * Resets the form, resets file name if required, reobtains preferences *//*from w ww . ja v a 2s .com*/ protected void StartLogging() { Log.d("GPSLOGSERV 101", "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); //ResetAutoSendTimersIfNecessary(); //ShowNotification(); //SetupAutoSendTimers(); ResetCurrentFileName(true); NotifyClientStarted(); StartPassiveManager(); StartGpsManager(); RequestActivityRecognitionUpdates(); }
From source file:com.trogdan.nanospotify.service.MusicService.java
/** * Configures service as a foreground service. A foreground service is a service that's doing * something the user is actively aware of (such as playing music), and must appear to the * user as a notification. That's why we create the notification here. *///from ww w . j av a 2s . c o m void setUpAsForeground(String text) { PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), MainActivity.class), PendingIntent.FLAG_UPDATE_CURRENT); mNotification = new Notification(); mNotification.tickerText = text; mNotification.icon = R.mipmap.ic_launcher; mNotification.flags |= Notification.FLAG_ONGOING_EVENT; mNotification.setLatestEventInfo(getApplicationContext(), getString(R.string.app_name), text, pi); startForeground(NOTIFICATION_ID, mNotification); }
From source file:android.app.Notification.java
@Override public Notification clone() { Notification that = new Notification(); that.when = this.when; that.icon = this.icon; that.number = this.number; // PendingIntents are global, so there's no reason (or way) to clone them. that.contentIntent = this.contentIntent; that.deleteIntent = this.deleteIntent; that.fullScreenIntent = this.fullScreenIntent; if (this.tickerText != null) { that.tickerText = this.tickerText.toString(); }/*from w ww. ja v a 2 s . com*/ if (this.tickerView != null) { that.tickerView = this.tickerView.clone(); } if (this.contentView != null) { that.contentView = this.contentView.clone(); } if (this.largeIcon != null) { that.largeIcon = Bitmap.createBitmap(this.largeIcon); } that.iconLevel = this.iconLevel; that.sound = this.sound; // android.net.Uri is immutable that.audioStreamType = this.audioStreamType; final long[] vibrate = this.vibrate; if (vibrate != null) { final int N = vibrate.length; final long[] vib = that.vibrate = new long[N]; System.arraycopy(vibrate, 0, vib, 0, N); } that.ledARGB = this.ledARGB; that.ledOnMS = this.ledOnMS; that.ledOffMS = this.ledOffMS; that.defaults = this.defaults; that.flags = this.flags; that.priority = this.priority; final String[] thiskind = this.kind; if (thiskind != null) { final int N = thiskind.length; final String[] thatkind = that.kind = new String[N]; System.arraycopy(thiskind, 0, thatkind, 0, N); } if (this.extras != null) { that.extras = new Bundle(this.extras); } that.actions = new Action[this.actions.length]; for (int i = 0; i < this.actions.length; i++) { that.actions[i] = this.actions[i].clone(); } if (this.bigContentView != null) { that.bigContentView = this.bigContentView.clone(); } return that; }
From source file:org.gaeproxy.GAEProxyService.java
@Override public void onCreate() { super.onCreate(); mShutdownReceiver = new BroadcastReceiver() { @Override//w ww . ja va 2s . c om public void onReceive(Context context, Intent intent) { stopSelf(); } }; IntentFilter filter = new IntentFilter(Intent.ACTION_SHUTDOWN); registerReceiver(mShutdownReceiver, filter); EasyTracker.getTracker().trackEvent("service", "start", getVersionName(), 0L); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); settings = PreferenceManager.getDefaultSharedPreferences(this); Intent intent = new Intent(this, GAEProxyActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); pendIntent = PendingIntent.getActivity(this, 0, intent, 0); notification = new Notification(); try { mStartForeground = getClass().getMethod("startForeground", mStartForegroundSignature); mStopForeground = getClass().getMethod("stopForeground", mStopForegroundSignature); } catch (NoSuchMethodException e) { // Running on an older platform. mStartForeground = mStopForeground = null; } try { mSetForeground = getClass().getMethod("setForeground", mSetForegroundSignature); } catch (NoSuchMethodException e) { throw new IllegalStateException("OS doesn't have Service.startForeground OR Service.setForeground!"); } }
From source file:jp.co.conit.sss.sp.ex1.billing.BillingService.java
/** * ????// w w w .j a va 2s .co m */ private void notificationRestore() { Context context = getApplicationContext(); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification(); Intent intent = new Intent(); PendingIntent pendingintent = PendingIntent.getActivity(context, 0, intent, 0); notification.icon = R.drawable.ic_status; notification.tickerText = context.getString(R.string.notification_restore); notification.flags = Notification.FLAG_AUTO_CANCEL; notification.setLatestEventInfo(context, context.getString(R.string.notification_restore), context.getString(R.string.notification_urge_download), pendingintent); notificationManager.notify(1, notification); }
From source file:jp.co.conit.sss.sp.ex1.billing.BillingService.java
/** * ????/*from w w w . j ava 2 s . com*/ * * @param purchases */ private void notificationVerifiedProduct(List<VerifiedProduct> purchases) { Context context = getApplicationContext(); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); HashMap<String, VerifiedProduct> orderMap = new HashMap<String, VerifiedProduct>(); int size = purchases.size() - 1; // ????Map??????????? for (int i = size; i >= 0; i--) { VerifiedProduct vp = purchases.get(i); if (vp.getPurchaseState() == PurchaseState.PURCHASED) { orderMap.put(vp.getProductId(), vp); } } // ?????Notification?? // ????? if (orderMap.size() > 0) { Notification notification = new Notification(); notification.icon = R.drawable.ic_status; notification.tickerText = context.getString(R.string.notification_buy_result); notification.flags = Notification.FLAG_AUTO_CANCEL; Intent intent = new Intent(); PendingIntent pendingintent = PendingIntent.getActivity(context, 0, intent, 0); String title = context.getString(R.string.notification_book); notification.setLatestEventInfo(context, context.getString(R.string.notification_buy_finish, title), context.getString(R.string.notification_urge_download), pendingintent); notificationManager.notify(0, notification); } }
From source file:com.geryon.ocraa.MusicService.java
/** * Configures service as a foreground service. A foreground service is a service that's doing * something the user is actively aware of (such as playing music), and must appear to the * user as a notification. That's why we create the notification here. *///from www . j ava 2 s . com void setUpAsForeground(String text) { PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), OCRAA.class), PendingIntent.FLAG_UPDATE_CURRENT); mNotification = new Notification(); mNotification.tickerText = text; mNotification.icon = R.drawable.ic_stat_playing; mNotification.flags |= Notification.FLAG_ONGOING_EVENT; mNotification.setLatestEventInfo(getApplicationContext(), "RandomMusicPlayer", text, pi); startForeground(NOTIFICATION_ID, mNotification); }