Created
January 8, 2018 16:11
-
-
Save nazmulidris/ecf2fb74b62449ee0bdf2df2d8ff9684 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @TargetApi(25) | |
| public static class PreO { | |
| public static void createNotification(Service context) { | |
| // Create Pending Intents. | |
| PendingIntent piLaunchMainActivity = | |
| getLaunchActivityPI(context); | |
| PendingIntent piStopService = getStopServicePI(context); | |
| // Action to stop the service. | |
| NotificationCompat.Action stopAction = | |
| new NotificationCompat.Action.Builder( | |
| STOP_ACTION_ICON, | |
| getNotificationStopActionText(context), | |
| piStopService) | |
| .build(); | |
| // Create a notification. | |
| Notification mNotification = | |
| new NotificationCompat.Builder(context) | |
| .setContentTitle(getNotificationTitle(context)) | |
| .setContentText(getNotificationContent(context)) | |
| .setSmallIcon(SMALL_ICON) | |
| .setContentIntent(piLaunchMainActivity) | |
| .addAction(stopAction) | |
| .setStyle(new NotificationCompat.BigTextStyle()) | |
| .build(); | |
| context.startForeground( | |
| ONGOING_NOTIFICATION_ID, mNotification); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment