Cornholio2108 / BestAlarm

0 stars 0 forks source link

Smart Shutdown notification #20

Closed Cornholio2108 closed 4 years ago

Cornholio2108 commented 4 years ago

Notification isn't canceled after smart shutdown is lifted. AlarmManager should have set intent for shutdown lifted time.

Cornholio2108 commented 4 years ago

Method changed. Testing needed.

Cornholio2108 commented 4 years ago

Might be helpful:

public static void stopService(Context context, Service s) {

        Intent i = new Intent(context, s.getClass());
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
            s.stopForeground(Service.STOP_FOREGROUND_DETACH);
            s.stopForeground(Service.STOP_FOREGROUND_REMOVE);
        } else {
            s.stopForeground(true);
        }
        context.stopService(i);
    }
Cornholio2108 commented 4 years ago

Service stopped properly now. Notification stays but can be deleted manually.