Android Basic Authentication 2.2+
<p>HI,</p>

<p>I am struggeling with Basic HTTP Authentication like I have seen many others..</p>

<pre><code>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&lt;String&gt; 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";
        }
    }
</code></pre>

<p>Where username &amp; password is a private final String.</p>

<p>But in my adb logcat I get:</p>

<p>E/GetHttpQuotes(  392): EXCEPTION in updateStatus() &lt;&lt; my log text"
E/GetHttpQuotes(  392): java.net.SocketException: Permission denied &lt;&lt; so something is wrong..</p>

<p>I tried so many code I found but nothing worked...</p>
