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 8520589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:34:39+00:00 2026-06-11T06:34:39+00:00

I try to run my android app on a device and my login crashed.

  • 0

I try to run my android app on a device and my login crashed. the logcat show this error

09-12 21:32:12.289: E/AudioHardwareALSA(149): RE-OPEN AFTER STANDBY:: took 115 msecs
09-12 21:32:12.319: E/AndroidRuntime(4760): FATAL EXCEPTION: main
09-12 21:32:12.319: E/AndroidRuntime(4760): android.os.NetworkOnMainThreadException
09-12 21:32:12.319: E/AndroidRuntime(4760):     at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1099)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at java.net.InetAddress.lookupHostByName(InetAddress.java:391)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at java.net.InetAddress.getAllByNameImpl(InetAddress.java:242)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at java.net.InetAddress.getAllByName(InetAddress.java:220)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:137)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at org.apache.http.impl.conn.AbstractPoolEntry.open(AbstractPoolEntry.java:164)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at org.apache.http.impl.conn.AbstractPooledConnAdapter.open(AbstractPooledConnAdapter.java:119)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:360)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:555)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:487)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:465)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at com.stts.sparetimetradingsystem.library.JSONParser.getJSONFromUrl(JSONParser.java:44)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at com.stts.sparetimetradingsystem.library.UserFunctions.loginUser(UserFunctions.java:40)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at com.stts.sparetimetradingsystem.LoginActivity$Login$1.run(LoginActivity.java:125)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at android.os.Handler.handleCallback(Handler.java:605)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at android.os.Looper.loop(Looper.java:137)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at android.app.ActivityThread.main(ActivityThread.java:4424)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at java.lang.reflect.Method.invokeNative(Native Method)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at java.lang.reflect.Method.invoke(Method.java:511)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
09-12 21:32:12.319: E/AndroidRuntime(4760):     at dalvik.system.NativeStart.main(Native Method)

Where did i done wrong?

EDIT

This is my login code where it is inside the async task, and can i know whether is my async task properly coded:

// Background ASYNC Task to login by making HTTP Request
class Login extends AsyncTask<String, String, String> {

    // Before starting background thread Show Progress Dialog
    @Override
    protected void onPreExecute() {
        super.onPreExecute();
        pDialog = new ProgressDialog(LoginActivity.this);
        pDialog.setMessage("Authenticating...");
        pDialog.setIndeterminate(false);
        pDialog.setCancelable(false);
        pDialog.show();
    }

    // Checking login in background
    protected String doInBackground(String... params) {
        runOnUiThread(new Runnable() {
            public void run() {

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

                // check for login response
                try {
                    if (json.getString(KEY_SUCCESS) != null) {
                        loginErrorMsg.setText("");
                        String res = json.getString(KEY_SUCCESS);
                        if (Integer.parseInt(res) == 1) {
                            validUser = true;
                            // user successfully logged in
                            // 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));
                        } else {
                            // Error in login
                            loginErrorMsg
                                    .setText("Incorrect username/password");
                        }
                    }
                } catch (JSONException e) {
                    e.printStackTrace();
                }

            }
        });
        return null;
    }

    // After completing background task Dismiss the progress dialog
    protected void onPostExecute(String file_url) {
        // dismiss the dialog once done
        pDialog.dismiss();
        if (validUser == true) {
            loginErrorMsg.setText("");
            // Launch HomePage Screen
            Intent homepage = new Intent(getApplicationContext(),
                    HomepageActivity.class);

            // Close all views before launching HomePage
            homepage.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(homepage);

            // Close Login Screen
            finish();
        }
    }
}
  • 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-11T06:34:40+00:00Added an answer on June 11, 2026 at 6:34 am

    You are using an AsyncTask but inside your doInBackground, you are actually executing your networking code through:

     runOnUiThread(new Runnable() { }
    

    That’s the reason why you end up with this exception, you need to execute your networking code without that. I guess you do it to have a reference to the application context, but it is rather simple just to provide it through the AsyncTask constructor.

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

Sidebar

Related Questions

I'm getting this error when I try run DB:Rake : ** Invoke db:migrate (first_time)
When I try to run my application as an Adroid App this is what
An Android app I've written is producing the following error message when run on
I try to run the following raw query in android, it seems not work
I try to run my project in windows. Project use android ndk. I install
I get this weird exception when i run my app on both the emulator
So my latest app runs into this problem where it complains in the logcat
I am trying to use Lombok with Android however whenever I try to run
I can run and debug my Android app on my phone just fine, most
I try to make android app with AdMob. I create the admob adView as

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.