Preserving login session across multiple Android apps

浪子不回头ぞ 提交于 2019-12-04 16:28:39

Shared user ID should get you access to each other's private storage, you would just need to figure out if the other was already installed, figure out the absolute path to its private storage and then look and see if it had the cookie. Hopefully you won't starve at the table of philosophers.

Err... what's it called... a data provider? Nope. I'm getting "Service" and "Content Provider" mixed up.

Put both apps and the login service in the same process. Either app should be able to start the service or query it for session info and anything else you might want to put there.

Alternatively, you can put all that information into a shared database.

The login dialog itself probably has to be an activity, and I'm not sure if you can have an activity within a service. You may need duplicate login screens in your apps that could then pass the session data to your service for sharing purposes.

I'm not sure if the service would have to be a separate install, or something that could be bundled with both apps.

Emmanuel

Here's a good solution:

What's the best way to do "application settings" in Android?

Since you want to share this between two applications, regardless of the way you want to implement it, don't forget that this will be visible to all applications. You may want to encrypt your password or session ID. Here's an example:

http://android.voxisland.com/code_examples/How_to_encrypt_and_decrypt_strings.rhtml

Good luck!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!