播放服务提示请求无法在请求时显示电话号码 [英] Play Services Hint Request cannot display phone numbers when requested

查看:247
本文介绍了播放服务提示请求无法在请求时显示电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用来自谷歌的短信提取器api 的代码时,首先抓住设备的电话号码,对话框显示一个加载微调器,然后迅速消失。在onActivityResult中,resultCode是1002,意图是空的。没有此错误代码的文档存在。我使用的确切代码是

  email.setOnClickListener(v  - > {

HintRequest ()。
.setPhoneNumberIdentifierSupported(true)
.setEmailAddressIdentifierSupported(false)
/ hintRequest.Builder()。setHintPickerConfig(new CredentialPickerConfig.Builder()。setPrompt(0).build /.setAccountTypes(IdentityProviders.GOOGLE)
.build();

PendingIntent intent =
Auth.CredentialsApi.getHintPickerIntent(mGoogleApiClient,hintRequest);
try {
startIntentSenderForResult(intent.getIntentSender(),599,null,0,0,0,null);
} catch(IntentSender.SendIntentException e){
Log.e(create,无法启动提示选择器Intent,e);
}
});


mGoogleApiClient = new GoogleApiClient.Builder(getContext())
.enableAutoManage(getActivity(),connectionResult - > {
Timber.e(conenction failed );
})
.addApi(Auth.CREDENTIALS_API)
.addApi(Auth.GOOGLE_SIGN_IN_API)
.build();

如果我要设置为真正的EmailAddressIdentifiedSupported,或者即使取消注释setAccountTypes,提示请求也会正常运行显示电子邮件帐户并将姓名和电子邮件返回给应用程序,但启用这两个帐户都不会导致凭据ID成为电话号码,如 1



这是从一个片段调用的,但是从任何位置调用startIntentSenderForResult的每一个变种都不会 ACTIVITY_RESULT_NO_HINTS_AVAILABLE (活动结果代码表示)。 没有可用的提示)



API参考文档> CredentialsAp i



要仅通过电话显示提示,请尝试仅使用 setPhoneNumberIdentifierSupported(true): ()

  HintRequest hintRequest = new HintRequest.Builder()
.setPhoneNumberIdentifierSupported(true)
.build();

同时尝试在其他帐户的设备上进行测试。


When using the code from google's sms retriever api to first grab the device's phone number, the dialog is shown with a loading spinner, then quickly disappears. In onActivityResult, the resultCode is 1002 and the intent is empty. No documentation for this error code exists. The exact code I'm using is

        email.setOnClickListener(v -> {

        HintRequest hintRequest = new HintRequest.Builder().setHintPickerConfig(new CredentialPickerConfig.Builder().setPrompt(0).build())
                .setPhoneNumberIdentifierSupported(true)
                .setEmailAddressIdentifierSupported(false)
                //.setAccountTypes(IdentityProviders.GOOGLE)
                .build();

        PendingIntent intent =
                Auth.CredentialsApi.getHintPickerIntent(mGoogleApiClient, hintRequest);
        try {
            startIntentSenderForResult(intent.getIntentSender(),599,null,0,0,0,null);
        } catch (IntentSender.SendIntentException e) {
            Log.e("create", "Could not start hint picker Intent", e);
        }
    });


    mGoogleApiClient =  new GoogleApiClient.Builder(getContext())
            .enableAutoManage(getActivity(),connectionResult -> {
                Timber.e("conenction failed");
            })
            .addApi(Auth.CREDENTIALS_API)
            .addApi(Auth.GOOGLE_SIGN_IN_API)
            .build();

If I were to set as true EmailAddressIdentifiedSupported OR even just uncomment setAccountTypes, then the hint request would function correctly showing email accounts and returning the name and email to the app, but enabling both does not cause the credential id to be the phone number as in 1

This is being called from a fragment, but calling every variety of startIntentSenderForResult from any location makes no difference.

解决方案

resultCode = 1002 means ACTIVITY_RESULT_NO_HINTS_AVAILABLE (Activity result code indicating that there were no hints available)

API Reference Doc > CredentialsApi

To display hints only by phone try to use only setPhoneNumberIdentifierSupported(true):

HintRequest hintRequest = new HintRequest.Builder()
.setPhoneNumberIdentifierSupported(true)
.build();

Also try to test on devices with other accounts.

这篇关于播放服务提示请求无法在请求时显示电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆