String basicAuth = Base64.encodeToString((username+":"+password).getBytes(), Base64.NO_WRAP);That is all. Thanks Stackoverflow
Having Trouble Using Authenticating With Api Using Basic Auth On Android?
You might want to take a look at your Base64 encoding. Make sure you use Base64.NO_WRAP, not Base64.DEFAULT, as I did. What NO_WRAP does is to make sure the string stays on one line, DEFAULT however does not (which will make tons of web servers very unhappy).
Working example: