I am newbie to android and this is my first project on android. I am struggling with \"authentication\" problem for more than a day. I tried several options but none of them
What version of Android are you testing on?
I had difficulties with the Android authenticator during some development work on Gingerbread (I don't know if it behaves differently on later versions of Android). I used Fiddler2 to examine the HTTP traffic between my app and the server, discovering that the authenticator did not send out the authentication string for every HTTP request. I needed it to.
Instead, I resorted to this:
urlConnection.setRequestProperty("Authorization", "Basic " + Base64.encodeToString("userid:pwd".getBytes(), Base64.NO_WRAP ));
It's a cut-and-paste from my code. Note that urlConnection is an HttpURLConnection object.