1111import android .content .Context ;
1212import android .content .ContextWrapper ;
1313import android .content .Intent ;
14+ import android .graphics .drawable .Icon ;
1415import android .net .Uri ;
1516import android .os .PowerManager ;
1617import android .provider .Settings ;
@@ -41,7 +42,6 @@ public ComponentName startService(Intent service) {
4142 return super .startService (service );
4243 }
4344
44- @ RequiresApi (23 )
4545 private boolean isIgnoringBatteryOptimizations () {
4646 PowerManager powerManager = (PowerManager ) getSystemService (POWER_SERVICE );
4747 return powerManager .isIgnoringBatteryOptimizations (getPackageName ());
@@ -130,8 +130,17 @@ private static Notification buildForegroundNotification(Context context, String
130130 );
131131
132132 // Notification actions
133- Action batteryAction = new Action .Builder (R .drawable .ic_battery_action , context .getString (R .string .foreground_action_battery_optimization ), batteryPendingIntent ).build ();
134- Action notificationAction = new Action .Builder (R .drawable .ic_notification_action , context .getString (R .string .foreground_action_notification_settings ), notificationCategoryPendingIntent ).build ();
133+ Action batteryAction = new Action .Builder (
134+ Icon .createWithResource (context , R .drawable .ic_battery_action ),
135+ context .getString (R .string .foreground_action_battery_optimization ),
136+ batteryPendingIntent
137+ ).build ();
138+
139+ Action notificationAction = new Action .Builder (
140+ Icon .createWithResource (context , R .drawable .ic_notification_action ),
141+ context .getString (R .string .foreground_action_notification_settings ),
142+ notificationCategoryPendingIntent
143+ ).build ();
135144
136145 Log .d (TAG , notifyTitle + " // " + firstLine + " // " + secondLine );
137146
@@ -143,7 +152,7 @@ private static Notification buildForegroundNotification(Context context, String
143152 .setStyle (new Notification .BigTextStyle ().bigText (firstLine + "\n " + secondLine ))
144153 .setPriority (Notification .PRIORITY_HIGH )
145154 .setShowWhen (false )
146- .setFullScreenIntent (notificationCategoryPendingIntent , true )
155+ .setContentIntent (notificationCategoryPendingIntent )
147156 .setContentIntent (mainSettingsPendingIntent )
148157 .addAction (batteryAction )
149158 .addAction (notificationAction )
0 commit comments