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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:20:05+00:00 2026-05-24T20:20:05+00:00

I got error on `onPreExecute()’ See my code : I have confuse here( download

  • 0

I got error on `onPreExecute()’

See my code :
I have confuse here(
download method (loadDailyDownloadData)contain in the different class & calling AsyncTask is different class…)

public class ListRoutesActivity extends Activity {

 public void onNextAction(View view){
    if(selectedRoutes.size() > 0){
        StringBuffer routeCode = new StringBuffer();
        for(int i=0; i<selectedRoutes.size();i++){
            routeCode.append("\'" + selectedRoutes.get(i) +"\'" +",");
        }
        routeCode.delete(routeCode.length() - 1,routeCode.length());
        strUField1 = routeCode.toString();
        new DailyDownldAsyncTask().execute();
    //  String s = new DownlaodTableActivity().loadDailyDownloadData(strBusinessUnit, strExecutive,strTerritoryCode,strUField1);
    //  System.out.println(" ---s - " + s);

    }else{
        Toast.makeText(ListRoutesActivity.this,"Please select the Route!",Toast.LENGTH_SHORT).show();
    }
     return;
 }



     public class DailyDownldAsyncTask extends AsyncTask<String, Integer, String> {
         private final ProgressDialog dialog = new ProgressDialog(ListRoutesActivity.this);
         int myProgress;

        @Override
        protected void onPostExecute(String result) {
            System.out.println(" ---- result--- " + result);
            if (this.dialog.isShowing()) {
                this.dialog.dismiss();
            }
            Toast.makeText(ListRoutesActivity.this,"Download successfully",Toast.LENGTH_SHORT).show();

        }

      @Override
      protected void onPreExecute() {

          this.dialog.setMessage("Downloading Table Data.......");
          this.dialog.show();
          myProgress = 0;
      }

      @Override
      protected String doInBackground(String... params) {
          return  new DownlaodTableActivity().loadDailyDownloadData(strBusinessUnit, strExecutive,strTerritoryCode,strUField1);

      }

      @Override
      protected void onProgressUpdate(Integer... values) {
          dialog.setProgress(values[0]);
      }
 }}

Here is my logcat :

08-19 17:45:18.933: ERROR/AndroidRuntime(472): FATAL EXCEPTION: main
08-19 17:45:18.933: ERROR/AndroidRuntime(472): java.lang.IllegalStateException: Could not execute method of the activity
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.view.View$1.onClick(View.java:2144)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.view.View.performClick(View.java:2485)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.view.View$PerformClick.run(View.java:9080)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.os.Handler.handleCallback(Handler.java:587)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.os.Handler.dispatchMessage(Handler.java:92)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.os.Looper.loop(Looper.java:123)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.app.ActivityThread.main(ActivityThread.java:3683)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at java.lang.reflect.Method.invokeNative(Native Method)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at java.lang.reflect.Method.invoke(Method.java:507)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at dalvik.system.NativeStart.main(Native Method)
08-19 17:45:18.933: ERROR/AndroidRuntime(472): Caused by: java.lang.reflect.InvocationTargetException
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at java.lang.reflect.Method.invokeNative(Native Method)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at java.lang.reflect.Method.invoke(Method.java:507)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.view.View$1.onClick(View.java:2139)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     ... 11 more
08-19 17:45:18.933: ERROR/AndroidRuntime(472): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token android.app.LocalActivityManager$LocalActivityRecord@4054c798 is not valid; is your activity running?
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.view.ViewRoot.setView(ViewRoot.java:527)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:177)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:91)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.view.Window$LocalWindowManager.addView(Window.java:424)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.app.Dialog.show(Dialog.java:241)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at com.xont.controller.admin.ListRoutesActivity$DailyDownldAsyncTask.onPreExecute(ListRoutesActivity.java:164)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at android.os.AsyncTask.execute(AsyncTask.java:391)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     at com.xont.controller.admin.ListRoutesActivity.onNextAction(ListRoutesActivity.java:100)
08-19 17:45:18.933: ERROR/AndroidRuntime(472):     ... 14 more

Without AsynTask my functionality is working fine that mean if I call new DownlaodTableActivity().loadDailyDownloadData(strBusinessUnit, strExecutive,strTerritoryCode,strUField1); this method directly without AsynTask , Its working fine

Please Help me
Thanks in advance

  • 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-05-24T20:20:08+00:00Added an answer on May 24, 2026 at 8:20 pm

    As it seems, your DownlaodTableActivity() is indeed not running. You can’t start an activity but just instantiating it, you need to call startActivity(Intent), passing the Intent for the activity you want to start.
    However, your code looks weird. The DownlaodTableActivity().loadDailyDownloadData(strBusinessUnit, strExecutive,strTerritoryCode,strUField1); method can be placed in a class that doesn’t extend activity, then you’ll have no problems. Hope this helps.

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

Sidebar

Related Questions

i have the code in c# string date = reader[date].ToString(); and got error that
while compiling the following code i have got error @Override public void routeCustomerRequest (int
I got error Access Violation when the following code is execute : void NoAction()
I'm trying to shake a window, but got error mess in console. My code:
I got an error today while trying to do some formatting to existing code.
I got error when I compile the following code, the error tells me that
I have got quite strange error in my OpenGL game. I would like to
I have been deploying fine with no problems. Today I got this error... rake
I have got folder binaries in my web application. I would like to download
redirect_to :controller=>'groups',:action=>'invite' but I got error because redirect_to send GET method I want to

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.