- Activity activity = getActivity();
- Context context = getContext();
-
- // Remove the incorrect lint warnings below that the activity and the context might be null.
- assert activity != null;
- assert context != null;
-
- // Get a handle for the shared preferences.
- SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
-
- // Get the screenshot and theme preferences.
- boolean darkTheme = sharedPreferences.getBoolean("dark_theme", false);
- boolean allowScreenshots = sharedPreferences.getBoolean("allow_screenshots", false);