A Preference is the basic building block of the Preference Library. A settings screen contains a Preference hierarchy. You can define this ...
Platform
AndroidStudio
GooglePlay
Jetpack
Kotlin
Docs
Games
Language
English
BahasaIndonesia
Español–AméricaLatina
Português–Brasil
TiếngViệt
中文–简体
中文–繁體
日本語
한국어
Signin
Documentation
Overview
Guides
Reference
Samples
Design&Quality
Platform
AndroidStudio
GooglePlay
Jetpack
Kotlin
Docs
Overview
Guides
Reference
Samples
Design&Quality
Games
AppBasics
Introduction
Buildyourfirstapp
OverviewCreateanAndroidprojectRunyourappBuildasimpleuserinterfaceStartanotheractivity
Appfundamentals
Appresources
OverviewHandleconfigurationchanges
Localization
LocalizeyourappTestyourappwithpseudolocalesUnicodeandinternationalizationsupportLanguageandlocaleresolutionComplexXMLresources
Resourcetypes
OverviewAnimationColorstatelistDrawableLayoutMenuStringStyleFontMoretypes
Appmanifestfile
Overview
Devices
Devicecompatibility
OverviewScreencompatibilityoverviewSupportdifferentpixeldensitiesDeclarerestrictedscreensupport
MultipleAPKsupport
OverviewCreatemultipleAPKsfordifferentAPIlevelsCreatemultipleAPKsfordifferentscreensizesCreatemultipleAPKsfordifferentGLtexturesCreatemultipleAPKswithseveraldimensionsSupportdifferentlanguagesandculturesSupportdifferentplatformversionsFiltersonGooglePlay
Tablets,largescreens,andfoldables
GetstartedwithlargescreensMediaprojectionEnhancedletterboxing
BuildresponsiveUIs
SupportdifferentscreensizesNavigationforresponsiveUIsMigrateyourUItoresponsivelayoutsActivityembeddingMulti-windowsupportInputcompatibilityonlargescreens
Buildforfoldables
LearnaboutfoldablesMakeyourappfoldawareTestyourapponfoldables
Wear
GetstartedPrinciplesofWearOSdevelopmentUpgradetothelatestversionofWearOSWearOSversusmobiledevelopmentWearOSuserinterface
Gettingstarted
WearOSdeveloperpathwayCreateandrunawearableappDebugaWearOSappCaptureWearUIscreenshots
Overlays
OverviewPlayingaudioonwearablesAuthenticationStandaloneappRequestpermissionsDetectlocationAppearinRecentsandAppResume
BuildingUIwithCompose
UseJetpackComposeonWearOSButtonsCardsChipsDialogsListsPageindicatorsPickersPositionindicatorProgressindicatorSlidersSteppersSwipetodismissTogglechipsTimetext
BuildingUIwithViews
BuildView-basedUIsonWearOSHandledifferentwatchshapesScreenoptionsCreatelistsNavigationExitfullscreenactivitiesonWearShowconfirmationsKeepyourappvisibleonWear
Tilesandcomplications
TilesoverviewWatchfacecomplicationsExposedatatocomplications
Notifications
NotificationsonWearOSBridgingoptionsfornotificationsOngoingActivities
Handlingdata
SendandsyncdataonWearOSNetworkaccessandsynconWearOSAccesstheWearableDataLayerTransferassetsSendandreceivemessagesHandledatalayereventsSyncdataitemswiththeDataLayerAPI
Userinput
PhysicalbuttonsRotaryinputCreateinputmethodeditorsinWearVoice
Healthservices
OverviewActivedataandexercisePassivedataupdatesUsesyntheticdataproviders
Design
DesignprinciplesGettingstartedInteractiontypesScreenshapesNotificationsComplicationsTilesTilesdesignsystemOverlaysOngoingactivitiesConfirmationoverlayDisconnectionindicatorsPermissionmessagesSelectioncontrolsLaunchandlatencyNavigationPermissionsSigninHardwarebuttonsColorTypographyIconsDownloadsWearMaterialTheming
Creatingwatchfaces
OverviewDesignwatchfacesBuildawatchfaceserviceDrawwatchfacesAddingcomplicationstoawatchfaceCreatinginteractivewatchfacesProvideconfigurationactivitiesAddresscommonissuesImproveperformacewithhardwareaccelerationOptimizeperformanceandbatterylife
WatchFaceStudio
WatchFaceStudioKeyboardshortcutsManageaWatchFaceStudioprojectCreateawatchfacewithWatchFaceStudioBuildcomplicationsinWatchFaceStudioTagexpressionsLanguagesettingsAlways-oninWatchFaceStudioGyroeffectsBuildanduploadfromWatchFaceStudioTestyourwatchfaceFAQWearappqualityPackageWearOSappsDistributetoWearOSCreateWearOSappsforChinaWearOSreleasenotes
AndroidTV
Overview
BuildTVApps
OverviewGetstartedwithTVappsAndroidXTVlibrariesHandleTVhardwareManageTVcontrollersBuildTVlayoutsOn-screenkeyboardCreateTVnavigationBestpracticesfordrivingengagementonGoogleTV
BuildTVplaybackapps
Overview
UIguidance&LeanbackAPI
CreateacatalogbrowserProvideacardviewBuildadetailsviewUsetransportcontrolsPlaybackcontrolsonTVAddaguidedstepIntroducefirst-timeuserstoyourappImplementamediasessionBackgroundplaybackinaNowPlayingcardAudiocapabilitiesMatchcontentframerate
HelpusersfindcontentonTV
Overview
RecommendTVcontent
OverviewChannelsonthehomescreenVideoprogramattributesAudioprogramattributesGameprogramattributes
WatchNext
AddprogramsAttributesGuidelinesforappdevelopersGuidelinesforTVprovidersPreviewvideosRecommendationsinAndroidNandearlierMakeTVappssearchableSearchwithinTVApps
BuildTVgames
OverviewUseStreamProtectforlatency-sensitivestreamingapps
BuildTVinputservices
OverviewDevelopaTVinputserviceWorkwithchanneldataManageTVuserinteractionSupporttime-shiftingSupportcontentrecordingTVAppschecklist
TVAccessibility
AccessibilitybestpracticesTalkBackevaluationexamplesAdoptsystemcaptionsettingsCustomviewaccessibilitysupportCustomviewaccessibilitysample
Releases
Android12forTV
Android13forTV(Beta)
OverviewWhat'snewforTV
AndroidforCars
Overview
Buildmediaappsforcars
BuildmediaappsforcarsAddsupportforAndroidAutoAddsupportforAndroidAutomotiveOSBuildmessagingappsforAndroidAuto
Buildnavigationandpointofinterestappsforcars
UsingtheAndroidforCarsAppLibraryBuildpointofinterestappsforcarsBuildnavigationappsforcarsAddsupportforAndroidAutoAddsupportforAndroidAutomotiveOSBuildvideoappsforAndroidAutomotiveOSTestAndroidappsforcarsDistributeAndroidappsforcarsGooglePlayservicesforcarsNotificationsonAndroidAutomotiveOS
ChromeOSdevices
OverviewBuildingappsforChromeOSOptimizingAppsforChromeOSPreparingyourdevelopmentenvironmentAppManifestCompatibilityforChromebooksChromeOSDeviceSupportforAppsAppRenderingDifferencesonChromebooksWindowmanagementAdaptingGamesonChromeOSSmoothanimationonChromeOSTestCasesforAndroidAppsonChromeOS
Apparchitecture
Introduction
Guidetoapparchitecture
Overview
UIlayer
OverviewUIeventsDomainlayerDatalayerLearningpathway
ArchitectureComponents
UIlayerlibraries
Viewbinding
OverviewMigratefromKotlinsyntheticstoviewbinding
Databindinglibrary
OverviewGetstartedLayoutsandbindingexpressionsWorkwithobservabledataobjectsGeneratedbindingclassesBindingadaptersBindlayoutviewstoArchitectureComponentsTwo-waydatabinding
Lifecycle-awarecomponents
HandlelifecyclesViewModelLiveDataSaveUIstatesSavedStatemoduleforViewModelUseKotlincoroutineswithlifecycle-awarecomponents
PagingLibrary
OverviewLoadanddisplaypageddataPagefromnetworkanddatabaseTransformdatastreamsManageandpresentloadingstatesTestyourPagingimplementationMigratetoPaging3
Paging2
OverviewDisplaypagedlistsLoadpageddata
Datalayerlibraries
DataStore
WorkManager
OverviewGettingStarted
How-ToGuides
DefiningyourWorkRequestsWorkstatesManagingworkObservingintermediateWorkerprogressChainingworktogetherTestingWorkerimplementationIntegrationtestswithWorkManagerDebuggingWorkManager
AdvancedConcepts
ConfigurationandInitialization
ThreadinginWorkManager
OverviewThreadinginWorkerThreadinginCoroutineWorkerThreadinginRxWorkerThreadinginListenableWorkerSupportforlong-runningworkersMigratingfromFirebaseJobDispatcherMigratingfromGCMNetworkManager
Appentrypoints
Activities
IntroductiontoactivitiesTheactivitylifecycleActivitystatechangesTestyouractivitiesTasksandbackstackProcessesandapplifecycleParcelablesandbundlesLoadersRecentsscreenRestrictionsonstartingactivitiesfromthebackground
Appshortcuts
OverviewCreateshortcutsAddcapabilitiesManageshortcutsBestpracticesforshortcuts
Appnavigation
PrinciplesofnavigationDesignfordifferentformfactorsHandleconfigurationchanges
Navigationcomponent
OverviewGettingstartedCreatedestinationsDesignnavigationgraphsNestedgraphsGlobalactionsNavigatetoadestinationSupportmultiplebackstacksConditionalnavigationPassdatabetweendestinationsCreateadeeplinkforadestinationAnimatetransitionsbetweendestinationsUpdateUIcomponentswithNavigationUIKotlinDSLInteractprogrammaticallyNavigatewithfeaturemodulesBestpracticesformulti-moduleprojectsTestnavigationAddnewdestinationtypesMigratetotheNavigationcomponent
Fragments
OverviewCreateafragmentFragmentmanagerFragmenttransactionsAnimatetransitionsbetweenfragmentsFragmentlifecycleSavingstatewithfragmentsCommunicatewithfragmentsWorkingwiththeappbarDisplayingdialogswithDialogFragmentDebugyourfragmentsTestyourfragments
Applinks
OverviewEnablinglinkstoappcontentVerifyapplinksCreateapplinksforinstantappsCreateswipeviewswithtabsusingViewPagerCreateswipeviewswithtabsusingViewPager2Providecustombacknavigation
Dependencyinjection
OverviewManualdependencyinjectionDependencyinjectionwithHiltHiltinmulti-moduleappsUseHiltwithotherJetpacklibrariesHilttestingguideHiltandDaggerannotationscheatsheet
Dagger
DaggerbasicsUsingDaggerinAndroidappsUsingDaggerinmulti-moduleapps
AppStartup
Coretopics
Appcompatibility
OverviewCompatibilityframeworktoolsRestrictionsonnon-SDKinterfaces
Interactwithotherapps
OverviewSendingtheusertoanotherappGettingaresultfromanactivityAllowingotherappstostartyouractivity
Packagevisibility
OverviewKnowwhichpackagesarevisibleautomaticallyDeclarepackagevisibilityneedsFulfillcommonusecasesTestpackagevisibility
Intentsandintentfilters
OverviewCommonintents
Userinterface
Overview
Layouts
OverviewBuildaresponsiveUIwithConstraintLayout
AddmotiontoyourlayoutwithMotionLayout
OverviewCarouselwithMotionLayoutMotionLayoutexamples
MotionLayoutXMLreference
OverviewCreatealistwithRecyclerViewAdvancedRecyclerViewcustomizationCreateacard-basedlayoutCreateatwopanelayout
Improvinglayoutperformance
OverviewOptimizinglayouthierarchiesRe-usinglayoutswithDelayedloadingofviewsLinearlayoutAdapterviewRelativelayout
Customviewcomponents
OverviewCreatingacustomviewclassImplementingcustomdrawingMakingtheviewinteractiveOptimizingtheviewDesigningforfoldables
Lookandfeel
MaterialdesignStylesandthemesDarkthemeRoundedcornersAdaptiveiconsAddafloatingactionbuttonCreateshadowsandclipviews
Text
AutosizingTextViewsDownloadablefontsFontsinXML
Emoji
SupportmodernemojiEmojicompatibilityMagnifierwidgetSpansButtonsCheckboxesRadiobuttonsTogglebuttonsSpinnersPickersTooltips
Notifications
OverviewCreateanotificationCreateanexpandablenotificationDisplaytime-sensitivenotificationsStartanactivityfromanotificationCreateagroupofnotificationsCreateandmanagenotificationchannelsModifyanotificationBadgeCreateacustomnotification
Splashscreens
OverviewMigrateyourexistingsplashscreenConversationsBubbles
Addtheappbar
OverviewSetuptheappbarAddandhandleactionsAddanupactionUseactionviewsandactionproviders
Windowinsets
OverviewDisplayedge-to-edgeImmersivemodeSupportdisplaycutoutsControlthesoftwarekeyboard
Supportingswipe-to-refresh
OverviewAddingswipe-to-refreshtoyourappRespondingtoarefreshgestureToastsoverview
Pop-upmessagesoverview
OverviewBuildanddisplayapop-upmessageAddanactiontoamessageDialogsMenus
Settings
OverviewOrganizeyoursettingsCustomizeyoursettingsUsesavedvaluesBuildahierarchyincodeHandleotherformfactorsPreferencecomponentsandattributes
Search
OverviewCreatingasearchinterfaceAddingrecentquerysuggestionsAddingcustomsuggestionsSearchableconfiguration
Addingsearchfunctionality
OverviewSettingupthesearchinterfaceStoringandsearchingfordataRemainingbackwardcompatibleReceiverichcontentCopyandpasteDraganddropPicture-in-picturesupport
Creatingbackward-compatibleUIs
OverviewAbstractingthenewAPIsProxyingtothenewAPIsCreatinganimplementationwitholderAPIsUsingtheversion-awarecomponentDevicecontrol
Homechannelsformobileapps
OverviewMediaHomeBooksMediaHomeVideoMediaHomeAudio
Appwidgets
OverviewCreateasimplewidgetEnhanceyourwidgetCreateanadvancedwidgetUsewidgetcollectionsProvideflexiblewidgetlayoutsEnablewidgetconfigurationBuildanappwidgethost
Animations&transitions
OverviewIntroductiontoanimationsPropertyanimationoverviewAnimatedrawablegraphicsRevealorhideaviewusinganimationMoveaviewusinganimationMoveaviewusingaflinganimationEnlargeaviewusingazoomanimationAnimatemovementusingspringphysicsAutoanimatelayoutupdatesAnimatelayoutchangesusingatransitionCreateacustomtransitionanimationStartanactivityusingananimationSlidebetweenfragmentsusingViewPagerSlidebetweenfragmentsusingViewPager2MigratefromViewPagertoViewPager2Additionalresources
Images&graphics
OverviewDrawablesoverviewVectordrawablesoverviewHandlingbitmapsSelectingcolorswiththepaletteAPIReducingimagedownloadsizesHardwareacceleration
DrawingwithAGSLshaders
OverviewDifferencesbetweenAGSLandGLSLUsingAGSLinyourAndroidappAGSLQuickReferenceOpenGLES
DisplayinggraphicswithOpenGLES
OverviewBuildinganOpenGLESenvironmentDefiningshapesDrawingshapesApplyingprojectionandcameraviewsAddingmotionRespondingtotouchevents
Rendering
OverviewReducingoverdrawPerformanceandviewhierarchiesAnalyzingwithprofileGPUrenderingEnhancinggraphicswithwidecolorcontent
Audio&video
Audio&videooverview
Media3
Overview
Gettingstarted
UseamediasessiontomanageplaybackPlaymediainthebackground
ExoPlayer
ExoPlayerandMedia3ExoPlayertoMedia3mappingsMediacontrolsSupportedmediaformatsMediacodecs
Mediaapparchitecture
MediaapparchitectureoverviewUsingamediasession
Buildinganaudioapp
AudioappoverviewBuildingamediabrowserserviceBuildingamediabrowserclientMediasessioncallbacksUsingthemediacontrollertestapp
Buildingavideoapp
VideoappoverviewBuildingavideoplayeractivityMediasessioncallbacksCompatiblemediatranscodingRespondingtomediabuttonsHandlingchangesinaudiooutputManageaudiofocus
TheGoogleAssistant
TheGoogleAssistantandmediaappsMediaappsonGoogleAssistantdrivingmode
Routingbetweendevices
RoutingoverviewMediaRouteroverviewMediaRouteProvideroverviewControlamplitudewithVolumeShaperMediaPlayeroverviewMediaRecorderoverviewExoPlayerSharingaudioinputCapturevideoandaudioplaybackFramerateBestpracticesforsharingvideoAdditionalResourcesforMedia
Services
OverviewForegroundservicesBoundservicesAIDLoverview
Backgroundtasks
OverviewBackgroundthreadsBackgroundoptimizations
Broadcasts
OverviewImplicitBroadcastExceptions
Managedeviceawakestate
OverviewKeepthedeviceawakeSchedulealarmsUsingaListenableFuture
Permissions
OverviewEvaluatewhetheryourappneedspermissionsDeclareapppermissionsRequestapppermissionsExplainaccesstomoresensitiveinformationApppermissionsbestpracticesPermissionsusedonlyindefaulthandlersRestrictinteractionswithotherappsDefinecustompermissions
Appdata&files
OverviewStorageoverviewSavetoapp-specificstorage
Savetosharedstorage
OverviewMediaDocumentsandotherfilesDatasetsManageallfilesonastoragedeviceSavekey-valuedata
Savedatainalocaldatabase
OverviewDefinedatausingentitiesAccessdatausingDAOsDefinerelationshipsbetweenobjectsWriteasynchronousDAOqueriesCreateviewsintoadatabasePrepopulateyourdatabaseMigrateyourdatabaseTestanddebugyourdatabaseReferencecomplexdataMigratefromSQLitetoRoomSavedatausingSQLiteStorageusecasesandbestpractices
Sharingsimpledata
OverviewSendingsimpledatatootherappsReceivingsimpledatafromotherapps
Sharingfiles
OverviewSettingupfilesharingSharingafileRequestingasharedfileRetrievingfileinformation
SharingfileswithNFC
OverviewSendingfilestoanotherdeviceReceivingfilesfromanotherdevice
Printingfiles
OverviewPrintingphotosPrintingHTMLdocumentsPrintingcustomdocuments
Contentproviders
OverviewContentproviderbasicsCreatingacontentproviderOpenfilesusingstorageaccessframeworkCreateacustomdocumentproviderAppinstalllocation
Userdata&identity
OverviewAddsign-inworkflowShowabiometricauthenticationdialog
Autofillframework
OverviewOptimizeyourappforautofillBuildautofillservicesIntegrateautofillwithkeyboardsIdentifydeveloper-ownedappsReviewhowyourappcollectsandsharesuserdataAuditdataaccessGetauser-resettableadvertisingIDCalendarprovideroverview
Contactsprovider
OverviewRetrievingalistofcontactsRetrievingdetailsforacontactModifyingcontactsusingintentsDisplayingthequickcontactbadgeAccounttransfer
Databackup
OverviewBackupuserdataBackupkey-valuepairsTestbackupandrestoreBestpracticesforuniqueidentifiers
Rememberandauthenticateusers
OverviewRememberyouruserAuthenticatetoOAuth2servicesCreateacustomaccounttype
Userlocation
OverviewRequestlocationpermissionsGetthelastknownlocationChangelocationsettingsRequestlocationupdatesAccesslocationinthebackgroundCreateandmonitorgeofencesDetectwhenusersstartanactivityOptimizelocationforbatteryTestlocationworkflowsMigratetolocationandcontextAPIsAddmaps
Touch&input
OverviewInputevents
Usingtouchgestures
OverviewDetectcommongesturesTracktouchandpointermovementsAnimateascrollgestureSupportnavigationgesturesHandlemulti-touchgesturesDragandscaleManagetoucheventsinaViewGroup
Handlingkeyboardinput
OverviewSpecifyingtheinputmethodtypeHandlinginputmethodvisibilitySupportingkeyboardnavigationHandlingkeyboardactions
Supportinggamecontrollers
OverviewHandlingcontrolleractionsSupportingcontrollersacrossAndroidversionsSupportingmultiplegamecontrollers
Inputmethodeditors
CreatinganinputmethodImagekeyboardSpellingchecker
Camera
Chooseacameralibrary
CameraX
OverviewArchitectureConfiguration
Usecases
PreviewImagecaptureImageanalysisVideocapture
Advancedtopics
ExtensionsAPITransformoutputRotationsDevices
Camera2
OverviewCameracapturesessionsandrequestsCameralensesandcapabilitiesUsemultiplecamerastreamssimultaneouslyCamerapreviewMulti-CameraAPIExtensionsAPI
Camera(deprecated)
OverviewTakephotosRecordvideosControlthecameraCameraAPI
Sensors
OverviewSensorsoverviewMotionsensorsPositionsensorsEnvironmentsensorsRawGNSSmeasurements
Connectivity
Overview
Performingnetworkoperations
OverviewConnecttothenetworkManagenetworkusageReadingnetworkstateOptimizenetworkaccessOptimizenetworkdatausageMonitorconnectivitystatusandconnectionmeteringParseXMLdata
PerformnetworkoperationsusingCronet
OverviewSendasimplerequestCronetrequestlifecycleUseCronetwithotherlibraries
Reference
org.chromium.net
OverviewCallbackException
CronetEngine
Overview
CronetEngine.Builder
OverviewLibraryLoaderCronetExceptionInlineExecutionProhibitedExceptionNetworkExceptionQuicExceptionUploadDataProviderUploadDataProvidersUploadDataSink
UrlRequest
OverviewBuilderCallbackStatusStatusListener
UrlResponseInfo
OverviewHeaderBlockEnhanceyourappswith5GBuildclient-serverapplicationswithgRPC
Transferringdatawithoutdrainingthebattery
OverviewOptimizedownloadsforefficientnetworkaccessMinimizetheeffectofregularupdatesAvoidunoptimizeddownloads
Reducenetworkbatterydrain
OverviewCollectingnetworktrafficdataAnalyzingdatatrafficOptimizenetworkaccessOptimizeuser-initiatednetworkuseOptimizeapp-initiatednetworkuseOptimizeserver-initiatednetworkuseOptimizinggeneralnetworkuse
TransferdatausingSyncAdapters
OverviewCreateaStubAuthenticatorCreateaStubContentProviderCreateaSyncAdapterRunaSyncAdapter
Bluetooth
OverviewSetupBluetoothFindBluetoothdevicesConnectBluetoothdevicesTransferBluetoothdataBluetoothpermissionsBluetoothprofilesCompaniondevicepairing
BluetoothLowEnergy
OverviewFindBLEdevicesConnecttoaGATTserverTransferBLEdata
NFC
OverviewNFCbasicsAdvancedNFCHost-basedcardemulationoverview
Telecom
OverviewBuildacallingappPreventcallerIDspoofingTelephonyIDs
Wi-Fi
Wi-FiscanningoverviewWi-Fipeer-to-peerWi-FiAwareoverviewWi-FilocationwithRTTLocalOnlyHotspot
Discoverandconnect
OverviewUsenetworkservicediscoveryCreateP2PconnectionswithWi-FiUseWi-FiP2PforservicediscoveryWi-FiEasyConnect
Wi-Fiinfrastructure
Wi-FiinfrastructureoverviewWi-FisuggestionAPIforinternetconnectivityWi-FiNetworkRequestAPIforpeer-to-peerconnectivityPasspointSavenetworksandPasspointconfigurations
USB
OverviewAccessoryoverviewHostoverviewUWBVPNSessioninitiationprotocoloverviewOpenMobileAPIreadersupport
Renderscript
OverviewAdvancedRenderScriptMigratefromRenderScript
RuntimeAPIreference
OverviewNumericaltypesObjecttypesConversionfunctionsMathematicalconstantsandfunctionsVectormathfunctionsMatrixfunctionsQuaternionfunctionsAtomicupdatefunctionsTimefunctionsandtypesAllocationdataaccessfunctionsObjectcharacteristicsfunctionsKernelinvocationfunctionsandtypesInput/outputfunctionsDebuggingfunctionsGraphicsfunctionsandtypesIndex
Web-basedcontent
OverviewBuildingwebappsinWebViewManagingWebViewobjectsLoadlocalcontentDarkenwebcontentUserprivacyinWebViewcrashreportingSupportingdifferentscreensinwebappsDebuggingwebappsBestpracticesforwebappsTestingagainstfutureversionsofWebView
AndroidAppBundles
OverviewConfigurethebasemoduleBuildandtestyourappbundleAddcodetransparencyTheappbundleformatFrequentlyaskedquestions
GooglePlay
GooglePlayBillingGooglePlayCorelibraries
PlayPoints
OverviewCreateproductsandpromotionsDetectanddeliverproductsTestproducts
PlayAssetDelivery
OverviewIntegrateassetdelivery(Kotlin&Java)Integrateassetdelivery(native)Integrateassetdelivery(Unity)TargettexturecompressionformatsTestassetdelivery
PlayFeatureDelivery
OverviewConfigureinstall-timedeliveryConfigureconditionaldeliveryConfigureon-demanddeliveryOn-demanddeliverybestpracticesConfigureinstantdeliveryAdditionalresources
In-appreviews
OverviewIntegrateusingKotlinorJavaIntegrateusingnativecodeIntegrateusingUnityTestin-appreviews
In-appupdates
OverviewSupportin-appupdates(KotlinorJava)Supportin-appupdates(Native)Supportin-appupdates(Unity)Testin-appupdates
GooglePlayInstant
OverviewofGooglePlayInstant
Getstartedwithinstantapps
Createaninstant-enabledappbundleUXbestpracticesforapps
Getstartedwithinstantgames
OverviewUnitypluginUXbestpracticesforgamesMigratetoAndroidAppBundlesImplementclouddeliveryofassetsSupportGooglePlayGamesServicesInstantPlaygamesInstantPlaygameschecklistReducethesizeofyourinstantapporgameAddadstoyourinstantapporgameProvidemultipleentrypoints
IntegratewithFirebase
AddGoogleAnalyticsforFirebasetoyourinstantappUseFirebaseDynamicLinkswithinstantappsTechnicalrequirementschecklistGooglePlayInstantpolicy
Resources
ReferenceCodesamplesSDKreleasenotesInstantAppIntents
Support
KnownissuesStackOverflowPlayDeveloperAPI
PlayInstallReferrer
Overview
PlayInstallReferrerLibrary
OverviewReferenceReleasenotesPlayInstallReferrerAPIPlayIntegrityAPI
PlayRequirements
PlayPoliciesTargetAPILevelSupport64-bitarchitectures
ApplicationLicensing
OverviewLicensingOverviewSettingUpforLicensingAddingServer-SideVerificationAddingClient-SideVerificationLicensingReferenceAPKExpansionFiles
GoogleAssistant
Overview
Build
AppActionsoverviewImplementbuilt-inintentsCreateshortcuts.xmlPushdynamicshortcutstoAssistantReleasenotes
Test
GoogleAssistantplugin
Grow
OverviewIn-AppShortcutPromoSDK
Addmorefeatures
CustomintentsAndroidwidgetsForegroundappinvocationInlineinventoryWebinventoryAssistantsharingReadIt
Actions.xml
Actions.xmlmigrationguideActions.xmloverviewBuildAppActionsCreateactions.xmlWebinventoryAppActionstesttoolAndroidSlicesTroubleshootingSupport
Slices
OverviewGettingStartedSlicetemplates
On-devicesearch
Games
Develop
Overview
AndroidGameDevelopmentKit(AGDK)
OverviewLibrariesDownloadReleasenotesAndroidStudio
AndroidGameDevelopmentExtensionforVisualStudio
OverviewQuickstartConfigureaprojectDebuggerMeasureappperformanceModifybuild.gradlefilesforAndroidStudioSamplesReleasenotes
AndroidGPUInspector
OverviewQuickstartSupporteddevices
Systemprofiling
OverviewViewasystemprofileGPUperformancecounters
Analyzeasystemprofile
FrameprocessingtimesMemoryefficiencyTexturememorybandwidthusageVertexmemorybandwidthusageThreadscheduling
Frameprofiling
Overview
Analyzeaframeprofile
MostexpensiverenderpassesVertexformatsShaderperformance
FrameProfilerUI
PerformancepaneCommandspaneFramebufferpaneGeometrypaneReportpaneShaderpaneMemorypaneStatepaneTexturespaneTexturepanePipelineviewpaneSupportedVulkanextensionsTroubleshootAndroidPerformanceTuner
MemoryAdviceAPI
OverviewGetstarted
Improve
ImprovegameperformanceReducegamesize
Improvedeviceavailability
Support64-bitarchitecturesSupportallscreens
GameMode
OverviewOptimizewithGameModeAPIGameModeinterventions
VulkanandOpenGL
3DassetoptimizationVulkanPrerotationVertexdatamanagement
Distribute
Overview
GooglePlayGamesforPC
OverviewGetstarted
Setupyourgame
PCcompatibilityGraphicsconfiguration
Deviceinput
Setupinput
InputSDK
OverviewQuickstart
Continuity
OverviewContinuityrequirementsVerifyingrequirementsExistingidentitysolutionsUsetheemulatorTestonChromeOS
Publishanddeploy
PackageSubmitUpdateFAQGooglePlayInstantPlayasyoudownload
Health&fitnessapps
HealthConnect
Introduction
Platformoverview
ArchitectureDeveloperfunctionalityGetstarted
Dataanddatatypes
IntroductionDatatypesDifferentialchangesAPI
Commonworkflows
WritedataReaddataDeletedataAggregatedataWorkwithsessionsExceptionsFrequentlyaskedquestions
HealthConnectguidelines
HealthConnectpolicyrequirementFAQsUXdeveloperguidance
Migrate
HealthConnectAPIcomparisonguideFitAndroidAPItoHealthConnectmigrationguide
Bestpractices
Testing
TestappsonAndroid
Fundamentals
FundamentalsoftestingAndroidappsWhattotestinAndroidUsingtestdoublesinAndroid
Localtests
Buildlocaltests
Instrumentedtests
BuildinstrumentedtestsAutomateUItests
AndroidXtestlibraries
SetupprojectforAndroidXTestJUnit4ruleswithAndroidXTestAndroidJUnitRunner
Espresso
EspressoEspressobasicsEspressosetupinstructionsEspressocheatsheetEspressoidlingresourcesEspresso-IntentsEspressolistsMultiprocessEspressoEspressorecipesEspressoWebAccessibilitycheckingAdditionalResourcesforEspresso
Testingothercomponents
TestcontentprovidersTestyourserviceWriteautomatedtestswithUIAutomator
Performance
Overview
Inspectingperformance
AndroidStudioProfilers
Profilingandtracing
Systemtracing
Overview
Capturetrace
CaptureatraceinAndroidStudioCaptureatraceonadeviceCaptureatracefromthecommandlineNavigateareport
Customevents
DefinecustomeventsCustomtraceeventsinnativecodeInspectGPUrendering
Benchmarking
Overview
Macrobenchmark
WritingabenchmarkCapturethemetricsControlyourappAddinginstrumentationarguments
Microbenchmark
OverviewWritingabenchmarkProfilingabenchmarkAddinginstrumentationargumentsBuildingwithoutGradleBenchmarkinginCI
Improvingperformance
BaselineProfilesAppstartuplibrary
Guides
WorkinginthebackgroundPerformanceclassAppStandbyBucketsAppHibernationVerifyingAppBehaviorontheAndroidRuntime(ART)
Solvingcommonproblems
AppStartup
Slowrendering
KeepingyourappresponsiveImprovinglayoutperformanceRendering
Memory
OverviewofmemorymanagementMemoryallocationamongpropertiesManageyourapp'smemoryProcessesandthreads
Batteryandpower
OptimizefordozeandappstandbyMonitorthebatterylevelandchargingstateMonitorconnectivitystatusandconnectionmeteringDetermingandmonitordockingstateandtypeProfilebatteryusagewithBatterystatsandBatteryHistorianAnalyzepowerusewithBatteryHistorianTestpower-relatedissuesBackgroundoptimizationsReduceappsize
Monitoringperformance
AndroidVitals
OverviewStuckPartialWakeLocksExcessiveWakeupsExcessiveBackgroundWi-FiScansExcessiveBackgroundNetworkUsageANRsCrashesSlowRenderingFrozenFramesPermissionDenialsAppStartupTimeJankStatslibrary
Accessibility
Overview
Buildandtestappsforaccessibility
MakeappsmoreaccessiblePrinciplesforimprovingappaccessibilityTestyourapp'saccessibility
Advancedtopics
MakecustomviewsmoreaccessibleCreateyourownaccessibilityserviceAdditionalresources
Privacy
Privacybestpractices
Security
AppsecuritybestpracticesSecuritytipsSecuritywithdataSecuritywithdataacrossadditionalAndroidversionsSecuritywithHTTPSandSSLNetworksecurityconfigurationUpdatingyoursecurityprovidertoprotectagainstSSLexploits
ProtectingagainstsecuritythreatswithSafetyNet
OverviewSafetyNetAttestationAPISafetyNetSafeBrowsingAPISafetyNetreCAPTCHAAPISafetyNetVerifyAppsAPICryptographyAndroidKeystoreSystemVerifyinghardware-backedkeypairswithkeyattestationAndroidProtectedConfirmationSupportingDirectBootRunningembeddedDEXcodeAppsecurityimprovementprogram
SDKs
SDKbestpractices
BuildforBillions
OverviewConnectivityDevicecapabilityDatacostBatteryconsumptionUIandcontent
BuildforEnterprise
OverviewDeveloperguideWorkprofilesSetupmanagedconfigurations
Appfeedback
SendappfeedbacktoEMMsTestappfeedbackWorkcontactsDevicemanagementpolicies
Devicemanagement
OverviewBuildadevicepolicycontroller
Dedicateddevices
OverviewLocktaskmodeMultipleusersCookbookDevicecontrolNetworkingandtelephonySecuritySystemupdatesNetworkactivitylogging
Androidversions
OverviewAndroid12Android11Android10Android9Android8.0Android7.0Deviceadministration
AndroidDevelopers
Docs
Guides
Settings
PartofAndroidJetpack.
Note:Thisguideexplainshowtousethe
AndroidXPreferencelibrary.
StartingwithAndroid10,theplatformandroid.preferencelibraryis
deprecated.
Settingsallowuserstochangethefunctionalityandbehaviorofan
application.Settingscanaffectbackgroundbehavior,suchashowoftenthe
applicationsynchronizesdatawiththecloud,ortheycanbemorewide-reaching,
suchaschangingthecontentsandpresentationoftheuserinterface.
Therecommendedwaytointegrateuserconfigurablesettingsintoyour
applicationistousetheAndroidXPreferenceLibrary.Thislibrarymanagesthe
userinterfaceandinteractswithstoragesothatyoudefineonlytheindividual
settingsthattheusercanconfigure.ThelibrarycomeswithaMaterialtheme
thatprovidesaconsistentuserexperienceacrossdevicesandOSversions.
Gettingstarted
APreferenceisthebasicbuildingblockofthePreferenceLibrary.Asettings
screencontainsaPreferencehierarchy.Youcandefinethishierarchyasan
XMLresource,oryoucanbuildahierarchyincode.
Thesectionsbelowdescribehowtobuildasimplesettingsscreenusingthe
AndroidXPreferenceLibrary.
Note:Thisguideassumesyouareusing
androidx.preference:preference:1.1.0orhigher.Somefeaturesmightbe
unavailableonolderversionsofthelibrary.
Createahierarchy
ThefollowingexampleshowsasimplehierarchythatisdefinedviaXML:
Caution:Theroottagmustbea,andtheXMLresourcemustbe
placedintheres/xml/directory.
ThishierarchycontainstwoindividualPreferences:a
SwitchPreferenceCompat
thatallowsausertotoggleasettingonoroff,andabasicPreferencewith
nowidget.
Whenbuildingahierarchy,eachPreferenceshouldhaveauniquekey.
Note:SeetheAndroidSettingsDesignGuidelines
forrecommendationsonhowtoorganizeyoursettingsscreen.
Inflatethehierarchy
ToinflateahierarchyfromanXMLattribute,createa
PreferenceFragmentCompat,
override
onCreatePreferences(),
andprovidetheXMLresourcetoinflate,asshownintheexamplebelow:
Kotlin
classMySettingsFragment:PreferenceFragmentCompat(){
overridefunonCreatePreferences(savedInstanceState:Bundle?,rootKey:String?){
setPreferencesFromResource(R.xml.preferences,rootKey)
}
}
Java
publicclassMySettingsFragmentextendsPreferenceFragmentCompat{
@Override
publicvoidonCreatePreferences(BundlesavedInstanceState,StringrootKey){
setPreferencesFromResource(R.xml.preferences,rootKey);
}
}
YoucanthenaddthisFragmenttoyourActivityasyouwouldwithanyother
Fragment:
Kotlin
classMySettingsActivity:AppCompatActivity(){
overridefunonCreate(savedInstanceState:Bundle?){
super.onCreate(savedInstanceState)
supportFragmentManager
.beginTransaction()
.replace(R.id.settings_container,MySettingsFragment())
.commit()
}
}
Java
publicclassMySettingsActivityextendsAppCompatActivity{
@Override
protectedvoidonCreate(BundlesavedInstanceState){
super.onCreate(savedInstanceState);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.settings_container,newMySettingsFragment())
.commit();
}
}
ContentandcodesamplesonthispagearesubjecttothelicensesdescribedintheContentLicense.JavaandOpenJDKaretrademarksorregisteredtrademarksofOracleand/oritsaffiliates.
Lastupdated2021-10-27UTC.
[{
"type":"thumb-down",
"id":"missingTheInformationINeed",
"label":"MissingtheinformationIneed"
},{
"type":"thumb-down",
"id":"tooComplicatedTooManySteps",
"label":"Toocomplicated/toomanysteps"
},{
"type":"thumb-down",
"id":"outOfDate",
"label":"Outofdate"
},{
"type":"thumb-down",
"id":"samplesCodeIssue",
"label":"Samples/codeissue"
},{
"type":"thumb-down",
"id":"otherDown",
"label":"Other"
}]
[{
"type":"thumb-up",
"id":"easyToUnderstand",
"label":"Easytounderstand"
},{
"type":"thumb-up",
"id":"solvedMyProblem",
"label":"Solvedmyproblem"
},{
"type":"thumb-up",
"id":"otherUp",
"label":"Other"
}]
Twitter
Follow@AndroidDevonTwitter
YouTube
CheckoutAndroidDevelopersonYouTube
LinkedIn
ConnectwiththeAndroidDeveloperscommunityonLinkedIn
MoreAndroid
Android
AndroidforEnterprise
Security
Source
News
Blog
Podcasts
Discover
Gaming
MachineLearning
Privacy
5G
AndroidDevices
Largescreens
WearOS
AndroidTV
Androidforcars
AndroidThings
ChromeOSdevices
Releases
Android11
Android10
Pie
Oreo
Nougat
Marshmallow
Lollipop
KitKat
DocumentationandDownloads
AndroidStudioguide
Developersguides
APIreference
DownloadStudio
AndroidNDK
Support
Reportplatformbug
Reportdocumentationbug
GooglePlaysupport
Joinresearchstudies
Android
Chrome
Firebase
GoogleCloudPlatform
Allproducts
Privacy
License
Brandguidelines
Getnewsandtipsbyemail
Subscribe
Language
English
BahasaIndonesia
Español–AméricaLatina
Português–Brasil
TiếngViệt
中文–简体
中文–繁體
日本語
한국어