Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9119583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:25:51+00:00 2026-06-17T05:25:51+00:00

I’m following the excellent tutorial on Android login and register at http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/ I’ve implemented

  • 0

I’m following the excellent tutorial on Android login and register at http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/

I’ve implemented the code into my own project but i kept on getting errors. So I decided to try if his code was working and it did just fine. After many hours of searching what was wrong i just decided to copy his code and go from there. But even after just copy-pasting his code into my project I still keep on getting errors.

Here’s my logcat error, if anyone could point me in the right direction I would be very glad.

01-15 10:12:26.822: E/AndroidRuntime(1935): FATAL EXCEPTION: main
01-15 10:12:26.822: E/AndroidRuntime(1935): android.os.NetworkOnMainThreadException
01-15 10:12:26.822: E/AndroidRuntime(1935): at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)                                        
01-15 10:12:26.822: E/AndroidRuntime(1935):     at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at libcore.io.IoBridge.connectErrno(IoBridge.java:127)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at libcore.io.IoBridge.connect(IoBridge.java:112)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at java.net.Socket.connect(Socket.java:842)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:119)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:144)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at com.example.androidbasic12.library.JSONParser.getJSONFromUrl(JSONParser.java:42)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at com.example.androidbasic12.library.UserFunctions.loginUser(UserFunctions.java:38)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at com.example.androidbasic12.MainActivity$1.onClick(MainActivity.java:57)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at android.view.View.performClick(View.java:4202)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at android.view.View$PerformClick.run(View.java:17340)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at android.os.Handler.handleCallback(Handler.java:725)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at android.os.Handler.dispatchMessage(Handler.java:92)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at android.os.Looper.loop(Looper.java:137)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at android.app.ActivityThread.main(ActivityThread.java:5039)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at java.lang.reflect.Method.invokeNative(Native Method)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at java.lang.reflect.Method.invoke(Method.java:511)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
01-15 10:12:26.822: E/AndroidRuntime(1935):     at dalvik.system.NativeStart.main(Native Method)`

JSONParser.class:

public class JSONParser {

static InputStream is = null;
static JSONObject jObj = null;
static String json = "";

// constructor
public JSONParser() {

}

public JSONObject getJSONFromUrl(String url, List<NameValuePair> params) {

    // Making HTTP request
    try {
        // defaultHttpClient
        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost httpPost = new HttpPost(url);
        httpPost.setEntity(new UrlEncodedFormEntity(params));

        HttpResponse httpResponse = httpClient.execute(httpPost);
        HttpEntity httpEntity = httpResponse.getEntity();
        is = httpEntity.getContent();

    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    } catch (ClientProtocolException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }

    try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                is, "iso-8859-1"), 8);
        StringBuilder sb = new StringBuilder();
        String line = null;
        while ((line = reader.readLine()) != null) {
            sb.append(line + "\n");
        }
        is.close();
        json = sb.toString();
        Log.e("JSON", json);
    } catch (Exception e) {
        Log.e("Buffer Error", "Error converting result " + e.toString());
    }

    // try parse the string to a JSON object
    try {
        jObj = new JSONObject(json);            
    } catch (JSONException e) {
        Log.e("JSON Parser", "Error parsing data " + e.toString());
    }

    // return JSON String
    return jObj;

}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:25:52+00:00Added an answer on June 17, 2026 at 5:25 am

    You’re performing a network operation in your main UI thread. If your target SDK is 11 (Honeycomb) or higher this will throw a NetworkOnMainThreadException because this behaviour can block the UI and lead to an unresponsive app.

    You have to use an AsyncTask to get avoid this, by loading the data in its doInBackground(..) method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I've tracked down a weird MySQL problem to the two different ways I was
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.