我是Googles Android平台的新开发者 - 我的HTC Desire上周到了.
现在我需要一种方法来登录我现有的应用程序(Java,目前在jetty上运行).服务器应用程序是使用spring security 3.0.2开发的
在我的情况下,我想支持以下内容:如果用户使用googlemail/google-Account设置了他的Android手机(大多数用户都这样做),我想使用此帐户凭据自动登录我的服务器应用程序.
是否有支持该用例的Android框架?还是有其他选择吗?
我读过:http code.google.com intl/de-DE/apis/accounts/docs/OpenID.html
我们如何使用Google AppEngine上的应用登录如下:http://blog.notdot.net/2010/05/Authenticating-against-App-Engine-from-an-Android-app
Aro*_*olm 10
我想你想要的是使用AccountManager
要了解Google帐户的类型,请使用以下内容:
AuthenticatorDescription[] types = mAccountManager.getAuthenticatorTypes(); //
for (AuthenticatorDescription type : types) {
Log.d("account types", type.type);
}
Run Code Online (Sandbox Code Playgroud)
然后做类似的事情
AccountManager mAccountManager = AccountManager.get(context);
Account[] mAccounts = AccountManager.get(context).getAccountsByType("com.google");
// Choose which account to use if there are multiple google accounts registered, save to Account mAccount
AccountManagerFuture<options> response = mAccountManager.getAuthToken(mAccount, type, options, activity, mCallback, mHandler); // define callback and handler yourself for where to return
Run Code Online (Sandbox Code Playgroud)
当用户在mHandler中到达mCallback时,登录过程就完成了.如果用户尚未登录到他/她的Google帐户,则会使用通常的Google登录对话框.
亲自尝试一下,让我知道它是否对你有所帮助!
我不确定我是否理解您希望用户登录的位置。
请注意,您不能假设将使用哪种 Web 浏览器(默认浏览器、Opera Mobile、制造商浏览器等)。如果您只提供一个网站,则 Web 浏览器有责任了解用户。大多数人我已经登录了他们的谷歌帐户。Android 在这里有点无关。
如果您希望 Android 应用程序连接到 Web 服务而不提示输入登录名/密码,则无法使用 openID 来实现此目的。我建议对这个用例使用 oauth。
| 归档时间: |
|
| 查看次数: |
8796 次 |
| 最近记录: |