Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onCreate() {
- super.onCreate();
- if (Build.VERSION.SDK_INT >= 26) {
- String CHANNEL_ID = "my_channel_01";
- NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
- "My Channel",
- NotificationManager.IMPORTANCE_DEFAULT);
- ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel);
- Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
- .setContentTitle("A service is running in the background")
- .setContentText("").build();
- startForeground(1, notification);
- }
- }
Add Comment
Please, Sign In to add comment