/** Creates Statusbar Notification. */ protected void createStatusbarNotification() { // create pending intent Intent notificationIntent = new Intent(this, PrimitiveFtpdActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); // create notification int icon = R.drawable.ic_notification; CharSequence tickerText = getText(R.string.serverRunning); CharSequence contentTitle = getText(R.string.notificationTitle); CharSequence contentText = tickerText; // use main icon as large one Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); long when = System.currentTimeMillis(); Notification notification = new Notification.Builder(getApplicationContext()) .setTicker(tickerText) .setContentTitle(contentTitle) .setContentText(contentText) .setSmallIcon(icon) .setLargeIcon(largeIcon) .setContentIntent(contentIntent) .setWhen(when) .build(); notification.flags |= Notification.FLAG_NO_CLEAR; // notification manager NotificationUtil.createStatusbarNotification(this, notification); }
/** Removes Statusbar Notification. */ protected void removeStatusbarNotification() { NotificationUtil.removeStatusbarNotification(this); }