I've created an app which shows a notification if the budget is below 20%. Now I want that user can handle the notification (enable-disable) via Settings Preference. If the user disables the notification, he will not receive the notification. Here is my code for Settings preference:
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="notify"
android:title="Notification"
android:summary ="Click to turn on or off"
/>
<SwitchPreferenceCompat
android:defaultValue="true"
android:key="key_vibrate"
android:dependency="notify"
android:summary="Vibrate on new notification"
android:title="Vibrate" />