HI,
I am struggeling with Basic HTTP Authentication like I have seen many others..
public String getJSONObject()
{
try
{
String strURL = "deleted_manually_here";
StringBuilder result = new StringBuilder();
String base64EncodedCredentials = Base64.encodeToString(
(username+":"+password).getBytes(), Base64.DEFAULT);
HttpPost post = new HttpPost(strURL);
post.addHeader("Authorization", "Basic " + base64EncodedCredentials);
ResponseHandler<String> responseHandler=new BasicResponseHandler();
String responseBody=client.execute(post, responseHandler);
JSONObject response=new JSONObject(responseBody);
Log.d(TAG,"SUCCESS!");
return "B";
}
catch (Throwable t) {
Log.e(TAG, "EXCEPTION in updateStatus()", t);
return "N";
}
}
Where username & password is a private final String.
But in my adb logcat I get:
E/GetHttpQuotes( 392): EXCEPTION in updateStatus() << my log text”
E/GetHttpQuotes( 392): java.net.SocketException: Permission denied << so something is wrong..
I tried so many code I found but nothing worked…
The solution to this problem is pretty simple!
The Internet Permission in the Android Manifest was missing which is pretty fundamental to check in problems like these at first.
http://developer.android.com/reference/android/Manifest.permission.html#INTERNET