I am looking into building an android app, which holds some simple data (probably stored in sqlite). I also have a ap开发者_开发百科p engine app which I intend to be an online data store for the information (the app engine app is wrote in python).
The question here is, what is the best way to authenticate a user with the app and how to get the data from the android app to the Google data store?
Thanks
Mike
You could use Google Account authentication and follow this useful post about Authenticating against App Engine from an Android app
You can also give a look at the SampleSyncAdapter sample from the SDK
If you want to authenticate using OAuth, you can do that. The only trick is that you need to launch the flow in an internal WebView, because App Engine's OAuth implementation doesn't allow custom protocols in the redirect. I recommend the Signpost library. If you'd like an example, the 2cloud Android client is licensed under the MIT license (full disclosure, I'm the lead dev for 2cloud). The benefit of this is it allows you to support Android 1.5 and higher. The Accounts API is only supported starting in 2.1.
Another option is the Accounts API. @systempuntoout has good links for that, so I won't reinvent the wheel here.
Finally, it might be worth taking a look at the App Engine-powered Android Eclipse project that was demo'd at I/O this year. It makes keeping code in sync and shared between the two simple. Only downsides are it requires Android 2.2 or higher, and it requires you to write in Java on the App Engine side and GWT for the client side.
精彩评论