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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:45:06+00:00 2026-06-06T14:45:06+00:00

I am using asy task for doing loading proccess while the service is supposed

  • 0

I am using asy task for doing loading proccess while the service is supposed to take care about the connection.
I am getting some error on the line:

serviceIntent.putExtra("receiver",new DownloadReceiver(new Handler()));

when I am using AsyncTask and service to do the connection.
my code is for AsyncTask is:

 private class DownloadReceiver extends ResultReceiver{
public DownloadReceiver(Handler handler) {
    super(handler);
}

@Override
   protected void onReceiveResult(int resultCode, Bundle resultData) {
    super.onReceiveResult(resultCode, resultData);
  //  if (resultCode == DownloadService.UPDATE_PROGRESS) {
        int progress = resultData.getInt("progress");
     //   mProgressDialog.setProgress(progress);
     //   if (progress == 100) {
       //     mProgressDialog.dismiss();
        }
    }



  protected String doInBackground(String... params) {

    Intent serviceIntent = new Intent();
            serviceIntent.putExtra("url", "www.google.com");

            new DownloadReceiver(new Handler());
            serviceIntent.putExtra("receiver",new DownloadReceiver(new Handler()));
    serviceIntent.setAction("connection.DownloadService");
    context.startService(serviceIntent);

so what can be the problem?

  • 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-06T14:45:07+00:00Added an answer on June 6, 2026 at 2:45 pm
    if( this error == compile time error){
    `DownloadReceiver` class should implements the   Parcelable interface 
    }
    else{
    

    I think you are getting an error since you are creating the Handler object inside the doInBackground() method which executed in another thread than the UI one, then some where in your application you are accessing the UI Thread using that Handler object
    . Note : To do that correctly you SHOULD create the Handler in UI Thread. what a good place to do that for your case .

    onPostExecute
    

    or put it as a instance variable . and pass it in the constructor;

    }

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

Sidebar

Related Questions

Using android 2.3.3, I have a background Service which has a socket connection. There's
Using import datetime in python, is it possible to take a formatted time/date string
Using C#, I need a some code to use regular expressions to replace spaces
Using core data I'd like to fetch some data. My model uses some abstract
Using linq2sql I'm trying to take the string in txtOilChange and update the oilChange
I am trying to display some information about the data below the plot created
Using restlet, I want to make a post to android's c2dm service. I have
I'm using JFreeChart to create a Time Series Chart but while I'm passing Integer
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using Android 2.1+. I have a service that gets killed from time to time

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.