Show a biometric authentication dialog - Android Developers

文章推薦指數: 80 %
投票人數:10人

You can provide support for auth-per-use keys within your instance of BiometricPrompt . Such a key requires the user to present either a biometric credential or ... 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 GetstartedwithlargescreensLargescreencookbookMediaprojectionEnhancedletterboxing BuildresponsiveUIs SupportdifferentscreensizesNavigationforresponsiveUIsMigrateyourUItoresponsivelayoutsActivityembeddingMulti-windowsupportInputcompatibilityonlargescreens Buildforfoldables LearnaboutfoldablesMakeyourappfoldawareTestyourapponfoldables Wear GetstartedPrinciplesofWearOSdevelopmentUpgradetothelatestversionofWearOSWearOSversusmobiledevelopmentWearOSuserinterface Gettingstarted WearOSdeveloperpathwayCreateandrunawearableappDebugaWearOSappCaptureWearUIscreenshots Overlays OverviewStandaloneappsAuthenticationRequestpermissionsDetectlocationPlayingaudioonwearablesAppearinRecentsandAppResume BuildingUIwithCompose UseJetpackComposeonWearOSButtonsCardsChipsDialogsListsPageindicatorsPickersPositionindicatorProgressindicatorSlidersSteppersSwipetodismissTogglechipsTimetext BuildingUIwithViews BuildView-basedUIsonWearOSHandledifferentwatchshapesScreenoptionsCreatelistsNavigationExitfullscreenactivitiesonWearShowconfirmationsKeepyourappvisibleonWear Tilesandcomplications TilesoverviewWatchfacecomplicationsExposedatatocomplications Notifications NotificationsonWearOSBridgingoptionsfornotificationsOngoingActivities Handlingdata SendandsyncdataonWearOSNetworkaccessandsynconWearOSAccesstheWearableDataLayerTransferassetsSendandreceivemessagesHandledatalayereventsSyncdataitemswiththeDataLayerAPI Userinput PhysicalbuttonsRotaryinputCreateinputmethodeditorsinWearVoice Healthservices OverviewActivedataandexercisePassivedataupdatesUsesyntheticdataprovidersEnhanceappcompatibility Design DesignprinciplesGettingstartedInteractiontypesScreenshapesNotificationsComplicationsTilesTilesdesignsystemOverlaysOngoingactivitiesConfirmationoverlayDisconnectionindicatorsPermissionmessagesSelectioncontrolsLaunchandlatencyNavigationPermissionsSigninHardwarebuttonsColorTypographyIconsDownloadsWearMaterialTheming Creatingwatchfaces OverviewDesignwatchfacesBuildawatchfaceserviceDrawwatchfacesAddingcomplicationstoawatchfaceCreatinginteractivewatchfacesProvideconfigurationactivitiesAddresscommonissuesImproveperformacewithhardwareaccelerationOptimizeperformanceandbatterylife WatchFaceStudio WatchFaceStudioKeyboardshortcutsManageaWatchFaceStudioprojectCreateawatchfacewithWatchFaceStudioBuildcomplicationsinWatchFaceStudioTagexpressionsLanguagesettingsAlways-oninWatchFaceStudioGyroeffectsBuildanduploadfromWatchFaceStudioTestyourwatchfaceFAQWearappqualityPackageWearOSappsDistributetoWearOSCreateWearOSappsforChinaWearOSreleasenotes AndroidTV Overview BuildTVApps OverviewGetstartedwithTVappsAndroidXTVlibrariesHandleTVhardwareManageTVcontrollersBuildTVlayoutsOn-screenkeyboardCreateTVnavigationBestpracticesfordrivingengagementonGoogleTV BuildTVplaybackapps Overview UIguidance&LeanbackAPI CreateacatalogbrowserProvideacardviewBuildadetailsviewUsetransportcontrolsPlaybackcontrolsonTVAmbientmodeAddaguidedstepIntroducefirst-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 GooglePlayGamesServices OverviewGetstartedDownloads SetupPlayConsole SetupPlayGamesServicesEnablefeaturesCloudprojectmanagementPublish Managefeatures AchievementsLeaderboardsEventsSavedgamesFriendsSign-in UsetheAPIs Android GetstartedSign-inEnableserver-sideaccessAnti-piracy Addfeatures AchievementsLeaderboardsFriendsSavedgamesEventsPlayerstatsTroubleshooting Unity OverviewGetstarted Addfeatures AchievementsLeaderboardsSavedgamesEventsFriendsPlayerstatsCAPI-comingsoon PublishingAPI OverviewGetstartedUploadimagesManagementAPI Requirementsandguidelines QualitychecklistBrandingguidelinesQuotaandratelimitsDatadisclosurerequirementsTermsofserviceSupport 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 OverviewAndroidStudioProfilers Profilingandtracing Systemtracing Overview Capturetrace CaptureatraceinAndroidStudioCaptureatraceonadeviceCaptureatracefromthecommandlineNavigateareport Customevents DefinecustomeventsCustomtraceeventsinnativecodeInspectGPUrendering Benchmarking Overview Macrobenchmark WritingabenchmarkCapturethemetricsControlyourappAddinginstrumentationarguments Microbenchmark OverviewWritingabenchmarkProfilingabenchmarkAddinginstrumentationargumentsBuildingwithoutGradleBenchmarkinginCI Measureperformance OverviewExamples Improvingperformance OverviewBaselineProfilesAppstartuplibrary Guides WorkinginthebackgroundPerformanceclassAppStandbyBucketsAppHibernationVerifyingAppBehaviorontheAndroidRuntime(ART) Solvingcommonproblems AppStartup Slowrendering KeepingyourappresponsiveImprovinglayoutperformanceRendering Memory OverviewofmemorymanagementMemoryallocationamongpropertiesManageyourapp'smemoryProcessesandthreads Batteryandpower OptimizefordozeandappstandbyMonitorthebatterylevelandchargingstateMonitorconnectivitystatusandconnectionmeteringDetermingandmonitordockingstateandtypeProfilebatteryusagewithBatterystatsandBatteryHistorianAnalyzepowerusewithBatteryHistorianTestpower-relatedissuesBackgroundoptimizationsReduceappsize Monitoringperformance Overview AndroidVitals OverviewStuckPartialWakeLocksExcessiveWakeupsExcessiveBackgroundWi-FiScansExcessiveBackgroundNetworkUsageANRsCrashesSlowRenderingFrozenFramesPermissionDenialsAppStartupTimeJankStatslibrary Accessibility Overview Buildandtestappsforaccessibility MakeappsmoreaccessiblePrinciplesforimprovingappaccessibilityTestyourapp'saccessibility Advancedtopics MakecustomviewsmoreaccessibleCreateyourownaccessibilityserviceAdditionalresources Privacy Privacybestpractices Security AppsecuritybestpracticesSecuritytipsSecuritywithdataSecuritywithdataacrossadditionalAndroidversionsSecuritywithHTTPSandSSLNetworksecurityconfigurationUpdatingyoursecurityprovidertoprotectagainstSSLexploits ProtectingagainstsecuritythreatswithSafetyNet OverviewSafetyNetAttestationAPIDiscontinuingSafetyNetAttestationPlayIntegrityAPISafetyNetSafeBrowsingAPISafetyNetreCAPTCHAAPISafetyNetVerifyAppsAPICryptographyAndroidKeystoreSystemVerifyinghardware-backedkeypairswithkeyattestationAndroidProtectedConfirmationSupportingDirectBootRunningembeddedDEXcodeAppsecurityimprovementprogram SDKs SDKbestpractices BuildforBillions OverviewConnectivityDevicecapabilityDatacostBatteryconsumptionUIandcontent BuildforEnterprise OverviewDeveloperguideWorkprofilesSetupmanagedconfigurations Appfeedback SendappfeedbacktoEMMsTestappfeedbackWorkcontactsDevicemanagementpolicies Devicemanagement OverviewBuildadevicepolicycontroller Dedicateddevices OverviewLocktaskmodeMultipleusersCookbookDevicecontrolNetworkingandtelephonySecuritySystemupdatesNetworkactivitylogging Androidversions OverviewAndroid12Android11Android10Android9Android8.0Android7.0Deviceadministration AndroidDevelopers Docs Guides Showabiometricauthenticationdialog Onemethodofprotectingsensitiveinformationorpremiumcontentwithinyour appistorequestbiometricauthentication,suchasusingfacerecognitionor fingerprintrecognition.Thisguideexplainshowtosupportbiometriclogin flowsinyourapp. Note:TheBiometriclibraryexpandsuponthefunctionalityofthedeprecated FingerprintManager API. Declarethetypesofauthenticationthatyourappsupports Todefinethetypesofauthenticationthatyourappsupports,usethe BiometricManager.Authenticators interface.Thesystemallowsyoutodeclarethefollowingtypesof authentication: BIOMETRIC_STRONG AuthenticationusingaClass3biometric,asdefinedonthe Android11compatibility definition page. BIOMETRIC_WEAK AuthenticationusingaClass2biometric,asdefinedonthe Android11compatibility definition page. DEVICE_CREDENTIAL Authenticationusingascreenlockcredential–theuser'sPIN,pattern,or password. Inordertoenrollanauthenticator,theuserneedstocreateaPIN, pattern,orpassword.Iftheuserdoesn'talreadyhaveone,thebiometric enrollmentflowpromptsthemtocreateone. Todefinethetypesofbiometricauthenticationthatyourappaccepts,passan authenticationtypeorabitwisecombinationoftypesintothe setAllowedAuthenticators() method.Thefollowingcodesnippetshowshowtosupportauthenticationusing eitheraClass3biometricorascreenlockcredential. Kotlin //AllowsusertoauthenticateusingeitheraClass3biometricor //theirlockscreencredential(PIN,pattern,orpassword). promptInfo=BiometricPrompt.PromptInfo.Builder() .setTitle("Biometricloginformyapp") .setSubtitle("Loginusingyourbiometriccredential") //Can'tcallsetNegativeButtonText()and //setAllowedAuthenticators(...orDEVICE_CREDENTIAL)atthesametime. //.setNegativeButtonText("Useaccountpassword") .setAllowedAuthenticators(BIOMETRIC_STRONGorDEVICE_CREDENTIAL) .build() Java //AllowsusertoauthenticateusingeitheraClass3biometricor //theirlockscreencredential(PIN,pattern,orpassword). promptInfo=newBiometricPrompt.PromptInfo.Builder() .setTitle("Biometricloginformyapp") .setSubtitle("Loginusingyourbiometriccredential") //Can'tcallsetNegativeButtonText()and //setAllowedAuthenticators(...|DEVICE_CREDENTIAL)atthesametime. //.setNegativeButtonText("Useaccountpassword") .setAllowedAuthenticators(BIOMETRIC_STRONG|DEVICE_CREDENTIAL) .build(); Note:Thefollowingcombinationsofauthenticatortypesaren'tsupportedon Android10(APIlevel29)andlower:DEVICE_CREDENTIALand BIOMETRIC_STRONG|DEVICE_CREDENTIAL.TocheckforthepresenceofaPIN, pattern,orpasswordonAndroid10andlower,usethe KeyguardManager.isDeviceSecure() method. Checkthatbiometricauthenticationisavailable Afteryoudecidewhichauthenticationelementsyourappsupports,checkwhether theseelementsareavailable.Todoso,passthe samebitwisecombinationoftypesthatyoupreviouslydeclaredintothe canAuthenticate()method. Ifnecessary,invokethe ACTION_BIOMETRIC_ENROLLintent action.Intheintentextra,providethesetofauthenticatorsthatyourapp accepts.Thisintentpromptstheusertoregistercredentialsforan authenticatorthatyourappaccepts. Kotlin valbiometricManager=BiometricManager.from(this) when(biometricManager.canAuthenticate(BIOMETRIC_STRONGorDEVICE_CREDENTIAL)){ BiometricManager.BIOMETRIC_SUCCESS-> Log.d("MY_APP_TAG","Appcanauthenticateusingbiometrics.") BiometricManager.BIOMETRIC_ERROR_NO_HARDWARE-> Log.e("MY_APP_TAG","Nobiometricfeaturesavailableonthisdevice.") BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE-> Log.e("MY_APP_TAG","Biometricfeaturesarecurrentlyunavailable.") BiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED->{ //Promptstheusertocreatecredentialsthatyourappaccepts. valenrollIntent=Intent(Settings.ACTION_BIOMETRIC_ENROLL).apply{ putExtra(Settings.EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, BIOMETRIC_STRONGorDEVICE_CREDENTIAL) } startActivityForResult(enrollIntent,REQUEST_CODE) } } Java BiometricManagerbiometricManager=BiometricManager.from(this); switch(biometricManager.canAuthenticate(BIOMETRIC_STRONG|DEVICE_CREDENTIAL)){ caseBiometricManager.BIOMETRIC_SUCCESS: Log.d("MY_APP_TAG","Appcanauthenticateusingbiometrics."); break; caseBiometricManager.BIOMETRIC_ERROR_NO_HARDWARE: Log.e("MY_APP_TAG","Nobiometricfeaturesavailableonthisdevice."); break; caseBiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE: Log.e("MY_APP_TAG","Biometricfeaturesarecurrentlyunavailable."); break; caseBiometricManager.BIOMETRIC_ERROR_NONE_ENROLLED: //Promptstheusertocreatecredentialsthatyourappaccepts. finalIntentenrollIntent=newIntent(Settings.ACTION_BIOMETRIC_ENROLL); enrollIntent.putExtra(Settings.EXTRA_BIOMETRIC_AUTHENTICATORS_ALLOWED, BIOMETRIC_STRONG|DEVICE_CREDENTIAL); startActivityForResult(enrollIntent,REQUEST_CODE); break; } Determinehowtheuserauthenticated Aftertheuserauthenticates,youcancheckwhethertheuserauthenticatedusing adevicecredentialorabiometriccredentialbycalling getAuthenticationType(). Displaytheloginprompt Todisplayasystempromptthatrequeststheusertoauthenticateusing biometriccredentials,usethe Biometriclibrary.This system-provideddialogisconsistentacrosstheappsthatuseit,creatinga moretrustworthyuserexperience.AnexampledialogappearsinFigure1. Figure1.Systemdialogrequestingbiometric authentication ToaddbiometricauthenticationtoyourappusingtheBiometriclibrary, completethefollowingsteps: Inyourappmodule'sbuild.gradlefile,addadependencyonthe androidx.biometric library. Intheactivityorfragmentthathoststhebiometriclogindialog,display thedialogusingthelogicshowninthefollowingcodesnippet: Kotlin privatelateinitvarexecutor:Executor privatelateinitvarbiometricPrompt:BiometricPrompt privatelateinitvarpromptInfo:BiometricPrompt.PromptInfo overridefunonCreate(savedInstanceState:Bundle?){ super.onCreate(savedInstanceState) setContentView(R.layout.activity_login) executor=ContextCompat.getMainExecutor(this) biometricPrompt=BiometricPrompt(this,executor, object:BiometricPrompt.AuthenticationCallback(){ overridefunonAuthenticationError(errorCode:Int, errString:CharSequence){ super.onAuthenticationError(errorCode,errString) Toast.makeText(applicationContext, "Authenticationerror:$errString",Toast.LENGTH_SHORT) .show() } overridefunonAuthenticationSucceeded( result:BiometricPrompt.AuthenticationResult){ super.onAuthenticationSucceeded(result) Toast.makeText(applicationContext, "Authenticationsucceeded!",Toast.LENGTH_SHORT) .show() } overridefunonAuthenticationFailed(){ super.onAuthenticationFailed() Toast.makeText(applicationContext,"Authenticationfailed", Toast.LENGTH_SHORT) .show() } }) promptInfo=BiometricPrompt.PromptInfo.Builder() .setTitle("Biometricloginformyapp") .setSubtitle("Loginusingyourbiometriccredential") .setNegativeButtonText("Useaccountpassword") .build() //Promptappearswhenuserclicks"Login". //Considerintegratingwiththekeystoretounlockcryptographicoperations, //ifneededbyyourapp. valbiometricLoginButton= findViewById



請為這篇文章評分?