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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T10:01:03+00:00 2026-06-06T10:01:03+00:00

I am developing an android application where in each activity i need to pass

  • 0

I am developing an android application where in each activity i need to pass some data onto the server and get back the responses before going to the next activity. The application works fine if the internet is fast enough. But as the speed goes down the application force closes. How to deal with slow internet connection so that it might not lead to force close of application?????

Here is some part of code

public void onClick(View v) {
    // TODO Auto-generated method stub
    UserFunctions userFunction = new UserFunctions();
    if(userFunction.isNetworkAvailable(getApplicationContext()))
    {
        answer="";
        for(int check1=0;check1<counter2;check1++){
            int check2=0;
            answer=answer+option4[check1]+"|";
            while(check2<counter1){
                if(edTxt[check1][check2].getText().toString().equals("")){
                    answer="";
                    break;
                }
                else{
                    answer=answer+edTxt[check1][check2].getText().toString()+"|";
                }
                check2++;       
            }   
            if(answer.equals("")){
                break;
            }
            else{
                answer=answer+"||";
            }
        }
        if(answer.equals("")){
            Toast.makeText(this, "Please fill all fields", 600).show();
        }
        else{
        userFunction.form1(surveyId,userId , quesNo, answer);
        if(total>0){
            draw(temp); 
        }
        else{
            ques_no++;
            ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();  
            params.add(new BasicNameValuePair("quesNo", Integer.toString(ques_no)));
            params.add(new BasicNameValuePair("surveyId", surveyId));
            count = getJsonFromURL22(surveyCond, params);           
            j=Integer.parseInt(result);
            if(j==22)
            {
                Toast.makeText(this, "Survey Completed", 600).show();
                Intent home=new Intent(Format16.this, SurveyCompleted.class);
                UserFunctions userFunctions = new UserFunctions();
                userFunctions.full(surveyId);
                Bundle d=new Bundle();
                d.putString("userId", userId);
                home.putExtras(d);
                startActivity(home);
            }
     public String getJsonFromURL22(String url, List<NameValuePair> params){
try{
    HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost(url);
    httppost.setEntity(new UrlEncodedFormEntity(params));
    HttpResponse response = httpclient.execute(httppost);
    HttpEntity entity = response.getEntity();
    is = entity.getContent();
}catch(Exception e){
    Log.e("log_tag", "Error in http connection"+e.toString());
}
//convert response to string
try{
    BufferedReader reader = new BufferedReader(new InputStreamReader(is,"iso-8859-1"),8);
    sb = new StringBuilder();
    sb.append(reader.readLine());

    String line="0";
    while ((line = reader.readLine()) != null) {
        sb.append(line);
    }
    is.close();
    result=sb.toString();
}catch(Exception e){
    Log.e("log_tag", "Error converting result "+e.toString());
}
return result;
}
  • 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-06T10:01:04+00:00Added an answer on June 6, 2026 at 10:01 am

    The application works fine if the internet is fast enough. But as the
    speed goes down the application force closes.

    It clearly indicates that you are doing network operation on UI Thread.As per Google Docs if the Asynchronous operation is performed on Main thread and if it is taking more than 5 seconds then your application will show force close dialog which is very unpleasent for end user.

    In-fact if you try to run such application on latest android version (i.e 4.0 or later) It will not allow you to run application it will crash at start as soon as it detects that the asynchronous operation is performed on main thread.

    You must use AsyncTask or Handlers to perform long running application.

    Go through following blog to know more.

    http://android-developers.blogspot.in/2010/07/multithreading-for-performance.html

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

Sidebar

Related Questions

I am developing an android application that receives data about events from a server.
I am developing an Android application and I have some data saved locally in
im developing an Android application for twitter that will sync data coming from the
I'm developing an Android Application for a tablet (1024x768). I searched and find some
I am developing an application using TabHost. I am using android default back button
I am developing android application but i don't know how to integrate two activity
i used netbeans 6.5 for developing android application. i need to add LWUIT for
Need information about minimum hardware requirement for better experience in developing Android application. My
I am developing an application for Android where I need to remove gravity from
I am developing an android application which contains a ListAtivity class and get it

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.