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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:39:36+00:00 2026-05-23T18:39:36+00:00

I have a very strange issue in an application I’m writing. It may be

  • 0

I have a very strange issue in an application I’m writing. It may be as simple that I am misunderstanding something about Services, AsyncTasks and when I have access to the UI thread again.

The application consists of a main activity through which you navigate to multiple other activities. The app has two Services, one that sits in the background and periodically polls while the application is in foreground, and another that runs “AACPlayer” to stream a live radio stream.

One of the activities, the one that has the UI controls for the radio, starts the service for the radio. To do this an AsyncTask is fired to grab and parse the PLS file, and finally start the Service with the proper URL of the stream. The service is started that also initiates the AACPlayer. Once the stream has started playing, a broadcast is issued that says the stream has started playing. The broadcast receiver in the activity that holds the radio controls handles the intent and updates the UI.

This works great except for one race condition where through a seemingly random combination of leaving the app or backing out of the radio screen, before the Service has broadcasted its intent to update the UI, all other activities now seem to run outside of the UI thread. Every other activity fired up during this condition receives an exception that it’s in an illegal state and can not modify do anything UI related as we’re not running on the UI thread. The usual culprit exception message is: W/System.err( 3818): android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

Has anyone else encountered that suddenly the entire application no longer is running on its usual UI Thread, and all other activities report this exception? I don’t think I have any code that’s doing anything illegal that would trigger this error. No UI related things inside AsyncTasks. The callback that’s triggered by the broadcast receiver (receiving from the radio Service) does touch UI, but I can’t think of a different way to do this?

The problem is not fixed even when the application force quits itself, but gets remedied when the application is either force quit or has its data cleared from the Android Settings.

EDIT – As requested here’s some code that outlines the service being started and the activity that starts the service / controls the UI: https://gist.github.com/1080797

Any thoughts would be appreciated. Thanks.

  • 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-23T18:39:36+00:00Added an answer on May 23, 2026 at 6:39 pm

    Try moving the initialization of your PlayerServiceUpdateReceiver to onCreate(). I don’t think you need to reinitialize it on every onResume(), you just need to re-register it. Do you know what I mean?

    I think what is happening is that you’re getting callbacks to receivers that you’ve overwritten with new instances.

    Or I might be completely wrong and it’s the correct way to do it. Correct me if I’m wrong.

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

Sidebar

Related Questions

I am facing a very strange issue. I have a SharePoint webpart that displays
I am experiencing a very strange issue. I have developped an application locally and
I have a very strange issue that I cannot explain. I have my base
I have got a very strange input issue in which it seems that my
We have a very strange issue that we're dealing with. We have an MVC
I have a very strange issue with JQuery, its about a starting of JQuery
I have very strange issues in my application. I added a layout file with
I have a very strange issue on my hands. I have two IIS websites
I've websphere application server 7 network deployment, and am facing a very strange issue,
I have a strange issue with an Asp.NET MVC application. Using Asp.NET MVC 3

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.