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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:25:27+00:00 2026-05-26T10:25:27+00:00

I’m using a repeating alarm to trigger a BroadcastReceiver ( OnAlarmReceiver ) which in

  • 0

I’m using a repeating alarm to trigger a BroadcastReceiver (OnAlarmReceiver) which in turn calls WakefulIntentService.sendWakefulWork(context, PmNotificationService.class);

The doWakefulWork method is displayed below

protected void doWakefulWork(Intent intent) {
    // Load auth information from server
    Authentication.loadAuthenticationInformation(this);

    if (hasAuthInformation()) {
        getRequestParameters().execute(getRequestHandler());
    }
}

The getRequestParameters().execute(getRequestHandler()); line creates an AjaxRequest object, along with a RequestHandler object, and the idea was that once the Ajax request is completed, it would send the information back to the RequestHandler.

In this case the handler is the PmNotificationService class (which extends WakefulIntentService).

The problem, and thus the basis of my question is the following message:

05-12 12:09:08.139: INFO/ActivityManager(52): Stopping service: com.sofurry/.services.PmNotificationService

05-12 12:09:08.558: WARN/MessageQueue(333): Handler{4393e118} sending message to a Handler on a dead thread

05-12 12:09:08.558: WARN/MessageQueue(333): java.lang.RuntimeException: Handler{4393e118} sending message to a Handler on a dead thread

…

Obviously the service stops running as soon as it has sent off the request, as that request runs in another thread, and as a result hereof the Handler is dead.

So my question is: Can I keep the service and thus the handler alive until I get a response (ie. wait for that other thread)? I would prefer it if I could, as the AjaxRequest object is maintained by someone else, and is used throughout the entire application.

Update

I obviously missed one very important point, namely that the WakefulIntentService inherits from IntentService instead of Service which means it will stop itself after it has done its work. I have currently solved it by changing the doWakefulWork method slightly. Here’s the new one:

@Override
protected void doWakefulWork(Intent intent) {
    RequestThread thread = null;

    // Load auth information from server
    Authentication.loadAuthenticationInformation(this);

    if (hasAuthInformation()) {
        thread = getRequestParameters().execute(getRequestHandler());

        try {
            thread.join();
        } catch (InterruptedException ignored) {}
    }
}

I’m not sure if using thread.join() is the best way to manage this, so I’ll leave the question unanswered for a few days, before I post an answer, just in case someone has a better solution for it.

  • 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-26T10:25:28+00:00Added an answer on May 26, 2026 at 10:25 am

    IntentService already uses a background thread for onHandleIntent().
    Hence, do not use AsyncTask — just execute your code in onHandleIntent().

    Check https://groups.google.com/forum/#!topic/android-developers/YDrGmFDFUeU

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have a text area in my form which accepts all possible characters 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.