diff --git a/.idea/misc.xml b/.idea/misc.xml index 0a7e42f..6fd4e63 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -51,7 +51,7 @@ - + diff --git a/app/src/main/java/in/basulabs/shakealarmclock/Activity_RingAlarm.java b/app/src/main/java/in/basulabs/shakealarmclock/Activity_RingAlarm.java index 31281e7..6fd5558 100644 --- a/app/src/main/java/in/basulabs/shakealarmclock/Activity_RingAlarm.java +++ b/app/src/main/java/in/basulabs/shakealarmclock/Activity_RingAlarm.java @@ -145,8 +145,7 @@ public boolean onKeyDown(int keyCode, KeyEvent event) { private void onPowerButtonPressed() { Intent intent; - int powerBtnAction = sharedPreferences.getInt(ConstantsAndStatics.SHARED_PREF_KEY_DEFAULT_POWER_BTN_OPERATION, - ConstantsAndStatics.DISMISS); + int powerBtnAction = sharedPreferences.getInt(ConstantsAndStatics.SHARED_PREF_KEY_DEFAULT_POWER_BTN_OPERATION, ConstantsAndStatics.DISMISS); if (powerBtnAction == ConstantsAndStatics.DISMISS) { intent = new Intent(ConstantsAndStatics.ACTION_CANCEL_ALARM); sendBroadcast(intent); diff --git a/app/src/main/java/in/basulabs/shakealarmclock/Service_SnoozeAlarm.java b/app/src/main/java/in/basulabs/shakealarmclock/Service_SnoozeAlarm.java index 43f669c..bdda91f 100644 --- a/app/src/main/java/in/basulabs/shakealarmclock/Service_SnoozeAlarm.java +++ b/app/src/main/java/in/basulabs/shakealarmclock/Service_SnoozeAlarm.java @@ -60,6 +60,9 @@ public void onReceive(Context context, Intent intent) { @Override public int onStartCommand(Intent intent, int flags, int startId) { + notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); + assert notificationManager != null; + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { startForeground(NOTIFICATION_ID, buildSnoozeNotification(), ServiceInfo.FOREGROUND_SERVICE_TYPE_NONE); } else { @@ -80,8 +83,6 @@ public int onStartCommand(Intent intent, int flags, int startId) { intentFilter.addAction(ConstantsAndStatics.ACTION_CANCEL_ALARM); registerReceiver(broadcastReceiver, intentFilter); - notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); - Service_SnoozeAlarm myInstance = this; ZonedDateTime alarmDateTime = ZonedDateTime.of(LocalDateTime.of( @@ -128,7 +129,6 @@ private void createNotificationChannel() { NotificationChannel channel = new NotificationChannel(Integer.toString(NOTIFICATION_ID), "in.basulabs.shakealarmclock Notifications", importance); //NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); channel.setSound(null, null); - assert notificationManager != null; notificationManager.createNotificationChannel(channel); } } @@ -155,8 +155,7 @@ private Notification buildSnoozeNotification() { //----------------------------------------------------------------------------------------------------- private void updateNotification() { - Intent intent = new Intent() - .setAction(ConstantsAndStatics.ACTION_CANCEL_ALARM); + Intent intent = new Intent().setAction(ConstantsAndStatics.ACTION_CANCEL_ALARM); PendingIntent contentPendingIntent = PendingIntent.getBroadcast(this, 5017, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(this, Integer.toString(NOTIFICATION_ID))