eas*_*ese 9 google-app-engine android credentials google-account google-cloud-endpoints
我使用安全的后端创建了一个端点,并且自从3月份开始在我正在构建的应用程序中使用它(源文档在这里).我最近在我的Android 6.0设备上安装了最新版本,弹出了一个奇怪的错误(它在4.2.2和5.1上完美运行).
具体错误是:
IllegalArgumentException: the name must not be empty: null
Run Code Online (Sandbox Code Playgroud)
我跟踪了凭证的错误,您可以看到下面的代码.在Android 6.0帐户可能是"user@gmail.com"但字符串'test'结果为null!
有什么特定的6.0改变了GoogleAccountCredential吗?
public static GoogleAccountCredential getCredential(Context ctx) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
String account = prefs.getString(UserProfileHelper.PREF_USER_ACCOUNT, "");
GoogleAccountCredential credential = GoogleAccountCredential.usingAudience(ctx,
"server:client_id:MY_ACCOUNT_NUMS.apps.googleusercontent.com")
.setSelectedAccountName(account);
String test = credential.getSelectedAccountName();
return credential;
}
Run Code Online (Sandbox Code Playgroud)
And*_*ast 14
对于Android 6.0 Marshmallow,您需要在运行时请求权限https://developer.android.com/training/permissions/index.html
要获取这些凭据,您需要CONTACTS组中的GET_ACCOUNTS权限
https://developer.android.com/guide/topics/security/permissions.html#normal-dangerous
您必须在活动/片段中请求它并处理与您的应用程序相关的任何UX.
归档时间: |
|
查看次数: |
1917 次 |
最近记录: |