Jon*_*lls 14 android accountmanager
我想使用android AccountManager来同步我的webservice和应用程序(联系人和calander的标准同步)但是,AccountManager似乎只存储用户名和密码.我的Web服务需要三个凭据:用户名,密码和帐户.存储第三条信息的最佳做法是什么?
J. *_*vea 30
正如pablisco所解释的,您可以使用AccountManager通过addAccountExplicitly()的userData Bundle参数存储任意用户数据的能力:
final Bundle extraData = new Bundle();
extraData.putString("someKey", "stringData");
boolean accountCreated = am.addAccountExplicitly(account, password, extraData);
Run Code Online (Sandbox Code Playgroud)
稍后,例如在您的Authenticator的getAuthToken()方法中,您可以检索与您正在使用的帐户相关的数据:
String myData = am.getUserData(account, "someKey");
Run Code Online (Sandbox Code Playgroud)
不幸的是,在撰写本文时,您只能检索字符串,因此在首次构建Bundle时,您的数据应存储为String.希望这有助于某人.
| 归档时间: |
|
| 查看次数: |
10810 次 |
| 最近记录: |