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

  • Home
  • SEARCH
  • 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 8837639
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:46:42+00:00 2026-06-14T09:46:42+00:00

I was writing an application that required login and registration, so I look up

  • 0

I was writing an application that required login and registration, so I look up some tutorials on the net. I also bought and online hosting server to store my database. However I keep getting run time error while running the applications. I’ve been scratching for one whole day and still dont know the problem. I’d appreciate if anyone can give me some hint or clue, thank you.

Log Cat Error

11-14 22:22:13.071: E/AndroidRuntime(12901): FATAL EXCEPTION: main
11-14 22:22:13.071: E/AndroidRuntime(12901): android.os.NetworkOnMainThreadException
11-14 22:22:13.071: E/AndroidRuntime(12901):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1118)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at java.net.InetAddress.lookupHostByName(InetAddress.java:385)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at java.net.InetAddress.getAllByNameImpl(InetAddress.java:236)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at java.net.InetAddress.getAllByName(InetAddress.java:214)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:670)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:509)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at com.example.trafficmaster.library.JSONParser.getJSONFromUrl(JSONParser.java:42)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at com.example.trafficmaster.library.UserFunctions.registerUser(UserFunctions.java:61)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at com.example.trafficmaster.RegisterActivity$1.onClick(RegisterActivity.java:55)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at android.view.View.performClick(View.java:4211)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at android.view.View$PerformClick.run(View.java:17267)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at android.os.Handler.handleCallback(Handler.java:615)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at android.os.Handler.dispatchMessage(Handler.java:92)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at android.os.Looper.loop(Looper.java:137)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at android.app.ActivityThread.main(ActivityThread.java:4898)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at java.lang.reflect.Method.invokeNative(Native Method)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at java.lang.reflect.Method.invoke(Method.java:511)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
11-14 22:22:13.071: E/AndroidRuntime(12901):    at dalvik.system.NativeStart.main(Native Method)
11-14 22:22:18.251: D/dalvikvm(12901): GC_CONCURRENT freed 357K, 11% free 12504K/13895K, paused 4ms+9ms, total 46ms
11-14 22:22:25.251: I/Process(12901): Sending signal. PID: 12901 SIG: 9

My Register Main Class

public class RegisterActivity extends Activity {
    Button btnRegister;
    Button btnLinkToLogin;
    EditText inputFullName;
    EditText inputEmail;
    EditText inputPassword;
    TextView registerErrorMsg;

    // JSON Response node names
    private static String KEY_SUCCESS = "success";
    private static String KEY_ERROR = "error";
    private static String KEY_ERROR_MSG = "error_msg";
    private static String KEY_UID = "uid";
    private static String KEY_NAME = "name";
    private static String KEY_EMAIL = "email";
    private static String KEY_CREATED_AT = "created_at";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.register);


        // Importing all assets like buttons, text fields
        inputFullName = (EditText) findViewById(R.id.registerName);
        inputEmail = (EditText) findViewById(R.id.registerEmail);
        inputPassword = (EditText) findViewById(R.id.registerPassword);
        btnRegister = (Button) findViewById(R.id.btnRegister);
        btnLinkToLogin = (Button) findViewById(R.id.btnLinkToLoginScreen);
        registerErrorMsg = (TextView) findViewById(R.id.register_error);

        // Register Button Click event
        btnRegister.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {

                new MyInnerClass().execute();

                String name = inputFullName.getText().toString();
                String email = inputEmail.getText().toString();
                String password = inputPassword.getText().toString();
                UserFunctions userFunction = new UserFunctions();
                JSONObject json = userFunction.registerUser(name, email, password);

                // check for login response
                try {
                    if (json.getString(KEY_SUCCESS) != null) {
                        registerErrorMsg.setText("");
                        String res = json.getString(KEY_SUCCESS);
                        if(Integer.parseInt(res) == 1){
                            // user successfully registred
                            // Store user details in SQLite Database
                            DatabaseHandler db = new DatabaseHandler(getApplicationContext());
                            JSONObject json_user = json.getJSONObject("user");

                            // Clear all previous data in database
                            userFunction.logoutUser(getApplicationContext());
                            db.addUser(json_user.getString(KEY_NAME), json_user.getString(KEY_EMAIL), json.getString(KEY_UID), json_user.getString(KEY_CREATED_AT));
                            // Launch Dashboard Screen
                            Intent dashboard = new Intent(getApplicationContext(), DashboardActivity.class);
                            // Close all views before launching Dashboard
                            dashboard.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(dashboard);
                            // Close Registration Screen
                            finish();
                        }else{
                            // Error in registration
                            registerErrorMsg.setText("Error occured in registration");
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }
            }
        });
  • 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-14T09:46:44+00:00Added an answer on June 14, 2026 at 9:46 am

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

    You could use an AsyncTask to get around this, loading the data in its doInBackground(..).

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

Sidebar

Related Questions

I'm writing a .NET 4.0 application that requires access to a SQL Server (v10.50.1600)
I'm writing an ASP.NET application that requires users to log on to a server
I currently have an application I'm writing in c# (using .NET) that requires me
We are developing a web application using asp.net and sql server. We are required
I'm writing a deployment application that should install all required components before load main
I am writing an application using Sencha Touch that will require a login to
I am writing application (.NET 4.0) that should do post-request to SalesForce to submit
I'm writing a client/server application that requires the server needs to be able to
I'm writing a suite of applications that all require login to a server. It's
So I'm in the process of writing an ASP.NET application that requires to import

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.