public abstract class SettingsBaseFragment
extends android.preference.PreferenceFragment
PreferenceFragment implementation which inflates its layout from a style specified in
the current theme.
uiSettingsFragmentStyle| Constructor and Description |
|---|
SettingsBaseFragment() |
| Modifier and Type | Method and Description |
|---|---|
void |
addPreferencesFromIntent(android.content.Intent intent)
Adds a preferences from the specified intent and registers this fragment as
Preference.OnPreferenceChangeListener on the current preference
screen and calls onPreferencesAdded(). |
void |
addPreferencesFromResource(int preferencesResId)
Adds a preferences from the specified preferencesResId Xml resource and registers
this fragment as
Preference.OnPreferenceChangeListener on the current
preference screen and calls onPreferencesAdded(). |
protected int |
checkSelfPermission(String permission)
Delegated call to
ActivityCompat#checkSelfPermission(Context, String). |
protected void |
onBindPreferences()
Called immediately after
requestBindPreferences() if preferences for this fragment
has been already added via one of addPreferencesFromIntent(Intent) or
addPreferencesFromResource(int) methods. |
android.view.View |
onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState) |
void |
onDestroyView()
This implementation saves the current scroll position of the preferences list view.
|
protected void |
onPreferencesAdded()
Called immediately after
addPreferencesFromResource(int) or addPreferencesFromIntent(Intent)
when preferences for this fragment has been added into the associated preference screen. |
void |
onRequestPermissionsResult(int requestCode,
String[] permissions,
int[] grantResults) |
void |
onSaveInstanceState(android.os.Bundle state) |
void |
onViewCreated(android.view.View view,
android.os.Bundle savedInstanceState)
This implementation restores the first visible item's position and its offset.
|
protected void |
requestBindPreferences()
Requests binding of preferences via
onBindPreferences(). |
protected void |
setPreferenceScreenKeyModificator(PreferenceScreenKeyModificator keyModificator)
Sets a modificator that should be used to modify keys of preferences displayed in preference
screen associated with this fragment.
|
boolean |
shouldShowRequestPermissionRationale(String permission) |
protected void |
supportRequestPermissions(String[] permissions,
int requestCode)
Invokes
Fragment.requestPermissions(String[], int) on Android versions above Marshmallow
(including). |
findPreference, getPreferenceManager, getPreferenceScreen, onActivityCreated, onActivityResult, onCreate, onDestroy, onPreferenceTreeClick, onStart, onStop, setPreferenceScreendump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getContext, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLoaderManager, getParentFragment, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, hashCode, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isRemoving, isResumed, isVisible, onAttach, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onDestroyOptionsMenu, onDetach, onHiddenChanged, onInflate, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onResume, onTrimMemory, onViewStateRestored, registerForContextMenu, requestPermissions, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, toString, unregisterForContextMenuprotected void setPreferenceScreenKeyModificator(PreferenceScreenKeyModificator keyModificator)
If you want to store setting preferences in a multi-account application where each account
should have its associated set of settings stored separately, consider using Context.getSharedPreferences(String, int)
where you would create SharedPreferences for each of accounts by its unique identifier
used as name for shared preferences file. You can always attach the account dependent preferences
to a settings fragment via its associated PreferenceManager.
This approach is a more elegant and error-prone solution than specifying key modificator for
that matter.
keyModificator - The desired modificator. May be null to clear the current one.protected int checkSelfPermission(String permission)
ActivityCompat#checkSelfPermission(Context, String).permission - The desired permission for which to perform check.PackageManager.PERMISSION_GRANTED if you have the
permission, or PackageManager.PERMISSION_DENIED if not.public boolean shouldShowRequestPermissionRationale(String permission)
shouldShowRequestPermissionRationale in class android.app.Fragmentprotected void supportRequestPermissions(String[] permissions, int requestCode)
Fragment.requestPermissions(String[], int) on Android versions above Marshmallow
(including).
Calling this method on Android versions before MARSHMALLOW will be ignored.
permissions - The desired set of permissions to request.requestCode - Code to identify this request in onRequestPermissionsResult(int, String[], int[]).public void onRequestPermissionsResult(int requestCode,
String[] permissions,
int[] grantResults)
onRequestPermissionsResult in class android.app.Fragmentpublic void addPreferencesFromResource(int preferencesResId)
Preference.OnPreferenceChangeListener on the current
preference screen and calls onPreferencesAdded().addPreferencesFromResource in class android.preference.PreferenceFragmentpublic void addPreferencesFromIntent(android.content.Intent intent)
Preference.OnPreferenceChangeListener on the current preference
screen and calls onPreferencesAdded().addPreferencesFromIntent in class android.preference.PreferenceFragmentprotected void onPreferencesAdded()
addPreferencesFromResource(int) or addPreferencesFromIntent(Intent)
when preferences for this fragment has been added into the associated preference screen.
Default implementation invokes onBindPreferences() if binding of preferences has been
requested before actually adding them.
Note, that if this fragment has attached PreferenceScreenKeyModificator the added
preferences have already theirs keys modified.
#setPreferenceScreenKeyModificator(PreferenceScreenKeyModificator)
PreferenceFragment.getPreferenceScreen()protected void requestBindPreferences()
onBindPreferences().
If preferences for this fragment has not been added yet via one of addPreferencesFromResource(int)
or addPreferencesFromIntent(Intent) methods, a pending request to bind preferences
is registered and binding will be performed when onPreferencesAdded() is called,
otherwise call to this method immediately invokes onBindPreferences().
protected void onBindPreferences()
requestBindPreferences() if preferences for this fragment
has been already added via one of addPreferencesFromIntent(Intent) or
addPreferencesFromResource(int) methods.public android.view.View onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup container,
android.os.Bundle savedInstanceState)
onCreateView in class android.preference.PreferenceFragmentpublic void onViewCreated(android.view.View view,
android.os.Bundle savedInstanceState)
onViewCreated in class android.preference.PreferenceFragmentpublic void onDestroyView()
onDestroyView in class android.preference.PreferenceFragmentpublic void onSaveInstanceState(android.os.Bundle state)
onSaveInstanceState in class android.preference.PreferenceFragment