📜  android 通过意图广播接收器检测屏幕 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:03.053000             🧑  作者: Mango

代码示例1
if (Build.VERSION.SDK_INT >= 26) {
        String CHANNEL_ID = "your_channel_id";
        NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
                "Notification Channel Title",
                NotificationManager.IMPORTANCE_DEFAULT);

        ((NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE)).createNotificationChannel(channel);

        Notification notification = new NotificationCompat.Builder(this, CHANNEL_ID)
                .setContentTitle("")
                .setContentText("").build();

        startForeground(1, notification);
    }