0

I want to access an online music library from my android application to play its music. The music is accessible on a url lets say www.test.com/music.html.

In order to get to this website though you need to login on www.test.com/index.html

In my Android App I don't want to have to login. So how can I bypass the login screen?

I have thought about a persistent cookie that comes with the app, how can I include this into the android application?

Or is there another solution like putting the login information in the post request?

  • Be aware that if you build a mechanism to bypass log-in for Android devices, this could be also used by other clients as well. Also, to answer the question more details on how the log-in system is implemented on the server side are needed. – kgiannakakis May 14 '12 at 08:23

2 Answers2

3

Yes, cookies is right solution in case you use embedded WebView in your app to log-in. You will need to use CookieSyncManager for it, look through this tutorial.

If you perform the log-in by entering username and password to EditText and then sending it to server, then you'd better implement token-based authentication. However, you may simply save user credentials to SharedPreferences, but that's actually a bad practice.

Community
  • 1
  • 1
a.ch.
  • 8,285
  • 5
  • 40
  • 53
  • Then how do you perform the log-in? Just entering username and password to `EditText` and then sending it to server? If so, then... see edited answer :) – a.ch. May 14 '12 at 09:43
  • Right now it is just for testing purposes, I want to have the easiest solution possible, like saving the login information in Strings in my Class. But how can I create the cookies and all those kind of stuff – Sebastian Oberste-Vorth May 14 '12 at 09:48
  • [`SharedPreferences.Editor.putString(..)`](http://goo.gl/nDzoV) would be the simplest way. – a.ch. May 14 '12 at 09:50
  • And why are SharedPrefs a bad practice? – Sebastian Oberste-Vorth May 14 '12 at 09:52
  • Because it's a bad idea to store user name and password locally. At least, it should be encrypted then – a.ch. May 14 '12 at 09:54
0

You could give SharedPreferences a try: http://developer.android.com/guide/topics/data/data-storage.html#pref

Maz
  • 764
  • 5
  • 5