电话号码提示 API 允许选择电话号码。 根据docs,用户可以禁用电话号码共享。如何重新启用它? 在哪里可以找到自动填充屏幕?
这是我用来调用“选择电话号码”对话框的代码。当用户禁用“电话号码共享”后,它就不再起作用。
private val phoneNumberHintIntentResultLauncher: ActivityResultLauncher<IntentSenderRequest> =
registerForActivityResult(ActivityResultContracts.StartIntentSenderForResult()) { result ->
try {
val phoneNumber = Identity.getSignInClient(requireActivity()).getPhoneNumberFromIntent(result.data)
binding?.frgSetupAccountEtPhone?.setText(phoneNumber)
} catch (e: Exception) {
log(e)
}
}
private fun requestHint() {
val request: GetPhoneNumberHintIntentRequest = GetPhoneNumberHintIntentRequest.builder().build()
Identity.getSignInClient(requireActivity())
.getPhoneNumberHintIntent(request)
.addOnSuccessListener { result ->
val phoneRequest = IntentSenderRequest.Builder(result.intentSender).build()
phoneNumberHintIntentResultLauncher.launch(phoneRequest)
}
.addOnFailureListener {
log(it)
}
}
我尝试过
startActivityForResult(
Intent("com.google.android.gms.auth.api.credentials.PHONE_NUMBER_HINT_SETTINGS"),
rcPhoneNumberHint)
但是,它给了我
java.lang.SecurityException: Permission Denial: starting Intent { act=com.google.android.gms.auth.api.credentials.PHONE_NUMBER_HINT_SETTINGS cmp=com.google.android.gms/.auth.api.credentials.assistedsignin.ui.PhoneNumberHintSettingsActivity } from ProcessRecord{1343fc7 30196:com.example.app/u0a2478} (pid=30196, uid=12478) not exported from uid 10031
我猜他们已经通过设置阻止了此活动从外部启动
android:exported="false"
如果是这样的话,那我们就倒霉了。
如果有人帮助启动“PHONE_NUMBER_HINT_SETTINGS”,它将很有用。