Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (Objects.equals(intent.getAction(), IZIGaapsConstants.ACTION.STARTFOREGROUND_ACTION)) {
- Intent deviceLockCheck = new Intent(this, IZIGaapsForegroundNotification.class);
- deviceLockCheck .setAction(IZIGaapsConst.LOCK_START);
- PendingIntent preStartIntent = PendingIntent.getService(this, 0, deviceLockCheck , 0);
- NotificationCompat.Action startIt = new NotificationCompat.Action(R.drawable.ic_start_24dp,
- getString(R.string.screen_notification_action_start), precordStartIntent);
- startNotificationForeGround(createRecordingNotification(startIt).build(), IZIGaapsConst.DEVICE_LOCK_NOTIFICATION_ID);
- }else if (intent.getAction().equals(IZIGaapsConstants.ACTION.STOPFOREGROUND_ACTION)){
- stopForeground(true);
- stopSelf();
- }
- if (Objects.equals(intent.getAction(), IZIGaapsConst.LOCK_START)) {
- //i want the lock event to be start from here to check for devecie lock and unlock
- } else if (Objects.equals(intent.getAction(), IZIGaapsConst.LOCK_STOP)) {
- //you know the task :)
- }
- return START_STICKY;
- }
- private NotificationCompat.Builder createRecordingNotification(NotificationCompat.Action action) {
- Bitmap icon = BitmapFactory.decodeResource(getResources(),
- R.drawable.rec_icon);
- NotificationCompat.Builder notification = new NotificationCompat.Builder(this, IZIGaapsConst.RECORDING_NOTIFICATION_CHANNEL_ID)
- .setContentTitle(getResources().getString(R.string.screen_recording_notification_title))
- .setTicker(getResources().getString(R.string.screen_recording_notification_title))
- .setSmallIcon(R.drawable.rec_icon)
- .setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false))
- .setPriority(Notification.PRIORITY_MIN);
- if (action != null)
- notification.addAction(action);
- return notification;
- }
- private void startNotificationForeGround(Notification notification, int ID) {
- startForeground(ID, notification);
- }
Add Comment
Please, Sign In to add comment