Repository navigation
Expand file tree
/
Copy pathApp.java
More file actions
36 lines (29 loc) · 1.41 KB
/
Copy pathApp.java
File metadata and controls
36 lines (29 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package ru.meefik.linuxdeploy;
import android.app.Application;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.os.Build;
public class App extends Application {
public static final String SERVICE_CHANNEL_ID = "SERVICE_CHANNEL";
@Override
public void onCreate() {
super.onCreate();
// Create notification channels for Oreo and newer
createNotificationChannels();
}
private void createNotificationChannels() {
// Create the NotificationChannel, but only on API 26+ because
// the NotificationChannel class is new and not in the support library
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = getString(R.string.service_notification_channel_name);
String description = getString(R.string.service_notification_channel_description);
int importance = NotificationManager.IMPORTANCE_LOW;
NotificationChannel channel = new NotificationChannel(SERVICE_CHANNEL_ID, name, importance);
channel.setDescription(description);
// Register the channel with the system; you can't change the importance
// or other notification behaviors after this
NotificationManager notificationManager = getSystemService(NotificationManager.class);
notificationManager.createNotificationChannel(channel);
}
}
}