Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

android detect screen on by intent broadcast receiver

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);
    }
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #android #detect #screen #intent #broadcast #receiver
ADD COMMENT
Topic
Name
2+4 =