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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:49:12+00:00 2026-06-13T00:49:12+00:00

I am connecting from my Android app to a RESTful Web Service in Java.

  • 0

I am connecting from my Android app to a RESTful Web Service in Java. I am using AsyncTask to fetch the data. It works perfectly for normal amount of data. but when I have a huge amount of data, an Exception happens in the Android app. I tried to catch this exception, but I couldn’t:

private class LoadingDataFromServer extends AsyncTask<Void, Void, Void> {

        private boolean outOfMemory = false;

        @Override
        public void onPreExecute() {
            progress = ProgressDialog.show(main_activity, null,"Loading ...", true);
        }

        @Override
        protected void onPostExecute(Void result) {
            if(outOfMemory) {
                Toast.makeText(StatisticActivity.this, "Out of memory, select smaller criteria", Toast.LENGTH_SHORT).show();
                finish();
            }
            else
                setListView();
            try {
                progress.dismiss();
            } catch (Exception e) { }
        }

        @Override
        protected Void doInBackground(Void... params) {
            TextView txtProject = (TextView) main_activity.findViewById(R.id.project);
            txtProject.setBackgroundColor(Color.DKGRAY);
            txtProject.setText(project);

            TextView label = (TextView) main_activity.findViewById(R.id.label);
            label.setText(R.string.deliverable);
            try {
            loadStatistic();
            } catch (OutOfMemoryError e) {
                outOfMemory = true;
                progress.dismiss();
            } catch (RuntimeException e) {
                outOfMemory = true;
                progress.dismiss();
            } catch (Exception e) {
                outOfMemory = true;
                progress.dismiss();
            }
            return null;
        }
    }

This is the error I got:

10-14 22:24:10.952: ERROR/AndroidRuntime(4179): Uncaught handler: thread AsyncTask #3 exiting due to uncaught exception
10-14 22:24:10.962: ERROR/AndroidRuntime(4179): java.lang.RuntimeException: An error occured while executing doInBackground()
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at android.os.AsyncTask$3.done(AsyncTask.java:200)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at java.lang.Thread.run(Thread.java:1102)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179): Caused by: java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at android.os.Handler.<init>(Handler.java:121)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at android.widget.Toast.<init>(Toast.java:68)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at android.widget.Toast.makeText(Toast.java:231)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at se.softwerk.timelog.statistic.StatisticActivity$LoadingDataFromServer.doInBackground(StatisticActivity.java:301)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at se.softwerk.timelog.statistic.StatisticActivity$LoadingDataFromServer.doInBackground(StatisticActivity.java:1)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
10-14 22:24:10.962: ERROR/AndroidRuntime(4179):     ... 4 more

The exception is happening in doInBackground, but my exception handeling did not work. Can you help me?

  • 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-13T00:49:13+00:00Added an answer on June 13, 2026 at 12:49 am

    You should call any UI-related code from within onPreExecute(), onProgressUpdate(Progress... values) or onPostExecute(Result result) (which run in main thread, the UI thread), and use doInBackground(Params... params) only to perform CPU-intensive operations.

    Calling publishProgress(Progress... values) within doInBackground(Params... params) will send data to onProgressUpdate(Progress... values), where you can use it to update the UI.

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

Sidebar

Related Questions

I'm considering using a persistent connection to a cloud service from an Android app.
I am connecting to a DB2 database (DB2 v9.7.400.501) from my Java web application
I have successfully implemented this from android to a java httpservlet on google app
I'm getting an SSLPeerUnverifiedException: No Peer Certificate when connecting to a web service from
I understand how to receive and send data from an android app to a
i'm trying to send an http request from an Android app to a Java
I can't find any specific solution for connecting to Facebook from an Android app.
I am using webservices for connecting the android app with server side using ksoap2
In one of my android app, I am using push Notification from Urban Airship.
I need to fetch some data over the cloud from my app. I've watched

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.