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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:39:44+00:00 2026-06-05T13:39:44+00:00

My application want to upload data to backend. Upload functionality available 2 places. One

  • 0

My application want to upload data to backend. Upload functionality available 2 places. One is after put invoice, it need to upload to backend without afftect other UI, that means through Serviceanother upload functionality will show all table to user if the user click on Upload button need to upload, through AsyncTask.

Now the problem is, if I call same upload table method then it thow can't create handler inside thread that has not called looper.prepare() this error.

06-14 09:53:52.504: W/System.err(2288): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
06-14 09:53:52.514: W/System.err(2288):     at android.os.Handler.<init>(Handler.java:152)
06-14 09:53:52.514: W/System.err(2288):     at android.app.Activity.<init>(Activity.java:714)
06-14 09:53:52.514: W/System.err(2288):     at xont.ventura.controller.syn.UploadActivity.<init>(UploadActivity.java:43)
06-14 09:53:52.514: W/System.err(2288):     at xont.ventura.controller.service.UploadService.uploadUsingService(UploadService.java:102)
06-14 09:53:52.514: W/System.err(2288):     at xont.ventura.controller.service.UploadService$ServiceThread.run(UploadService.java:3872)

My code is :

  @Override
public void onStart(Intent intent, int startid) {
    Toast.makeText(this, "Upload Service Started", Toast.LENGTH_LONG).show();
    if(! APPURL.equals("")){
        serviceThread = new ServiceThread();
        serviceThread.start();
        if(result.equals("The operation timed out")) {
            Toast.makeText(this,"Service is not working  OR Time out to Connect to service !!!!!!!",Toast.LENGTH_LONG).show();
        }
    }else{
        Toast.makeText(this, "GPRS/WIFI is not available", Toast.LENGTH_LONG).show();
    }
    Log.d(TAG, "onStart");
}

    private class ServiceThread extends Thread {
    @Override
    public void run() {
         result = uploadUsingService();
    }   
};


    public String uploadUsingService(){
    uploadTable = getUploadTable();
    String result = "";
    try {
      //  dbAdapter.openDataBase();
        if(uploadTable.size() > 0){
            for (Map.Entry<Integer, String> entry : uploadTable.entrySet()) {
                String value = entry.getValue();
                if(value.equals("WMInvoiceHeader")){
                    result = new UploadActivity().getInvoiceHeader();
                }else if(value.equals("WMInvoiceLine")){
                    result = new UploadActivity().getInvoiceLine();
                }else if(value.equals("WMInvoiceHeaderDiscount")){
                    result = new UploadActivity().getInvoiceHeaderDiscount();
                }else if(value.equals("WMInvoiceSpecialDiscount")){
                    result = new UploadActivity().getInvoiceSpecialDiscount();
                }else if(value.equals("WMInvoiceCancelHeader")){
                    result = new UploadActivity().getInvoiceCancelHeader();
                }else if(value.equals("WMInvoiceCancelLine")){
                    result = new UploadActivity().getInvoiceCancelLine();
                }else if(value.equals("WMTransactionControl")){
                    result = new UploadActivity().getTransactionControl();
                }else if(value.equals("WMVisitDetail")){
                    result = new UploadActivity().getVisitDetail();
                }
                if(result.equals("The operation timed out")) break;
            }
        }
        //Toast.makeText(this, "Upload Service End", Toast.LENGTH_LONG).show();

    } catch (Exception e) {
        e.printStackTrace();
    }

    return result;
}

Here the problem is calling new UploadActivity().functionname If i write this function inside the same class. it doesn’t have any issue. like getInvoiceCancelLine() .If i write like this then 2 places have to write upload functionality method. How can i reusable same method 2 place.

Please help me out from this issuse?

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-06-05T13:39:46+00:00Added an answer on June 5, 2026 at 1:39 pm

    UI Thread(Event thread) is not thread safe, so you cant do any operation on UI into another thread.
    By seeing your code it seems you are doing some UI stuff into method

    getUploadTable()
    

    you can invoke this method outside of another thread, and then pass the result to ServiceThread.

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

Sidebar

Related Questions

i am making one application, what to use if i want to upload data
I've developed a windows form application. However,I want to upload data from that application
I have an Android application from which I want to upload some data to
I want to upload some data from an Android application to Pachube. [Update: For
I want to upload data through CSV files in my contact management application. The
In my application I want to upload file from SD card to my server.
I'm creating a very simple django upload application but I want to make it
I want to upload one image to the database by using Google app engine
In my application i want to upload the images to server. I am able
I have a facebook canvas application and I want to upload a file from

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.