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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:44:57+00:00 2026-06-09T07:44:57+00:00

I have an android app in which there are many scenarios where request and

  • 0

I have an android app in which there are many scenarios where request and response happens to-from server. For example:login i.e. authentication. When user enters username and password, then the credentials are verified against the one responded by Server.

But sometimes what happens is that due to slow network the response comes late and android pop-up a force close dialog box, which is highly embarrassing.

I was thinking that is there a way to segregate the code which hits the server in some separate thread and till it gets me a response. I may show a progress bar instead of force close. Is it a good solution?

Example code:

//this code will be called when user presses Login button on UI
public void authenticate(View view) {
      //the logic for authentication
      if(authentication==true){
         //go to home page
        }
}

In the above code how can I separate the logic for authentication so that force close does not occur when response is late as expected.

I would also appreciate any other better approach to tackle such scenarios of force close.

  • 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-09T07:44:59+00:00Added an answer on June 9, 2026 at 7:44 am

    Do not include any task which takes time to execute in your main thread. You should do httpCommunication in different thread. and it will avoid this ANR.

    What docs says >>
    In Android, application responsiveness is monitored by the Activity Manager and Window Manager system services. Android will display the ANR dialog for a particular application when it detects one of the following conditions:
    No response to an input event (e.g. key press, screen touch) within 5 seconds
    A BroadcastReceiver hasn’t finished executing within 10 seconds

    Read this document specially created for Designing for responsiveness and to avoid ANR

    You can use AsyncTask as well.

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

Sidebar

Related Questions

I have made an android app which working fine. I implemented the Login functionality
I have an android app which has native code. The native code needs to
I have an android app which let the user to submit a form ,
I have an Android app which is crashing on some phones, and not on
I have an Android app which calculates poker odds ( Shufflebot if you're interested).
I have an android app which gives the user the option of loading a
I have an Android app which includes an activity called Help This uses a
I have been trying to implement an upgrade plan for my Android app which
I have an Android app that I had working a few months ago which
I am developing an android app in which I have included a library project,

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.