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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:32:38+00:00 2026-05-23T05:32:38+00:00

I have an audio recording app, for which I am currently developing a widget.

  • 0

I have an audio recording app, for which I am currently developing a widget.

Recording is performed by an audio engine running in a service put in the foreground state.

Whenever the audio engine state changes to pause/play/record, a broadcast is sent, and handled by a receiver which updates the widget.

So that clicking on the record button in the widget starts recording, which causes the broadcast to be sent, and in the end the record button to turn red in the widget. Same thing happens if you start recording from within the app instead of the widget.

Everything’s good so far.

Now, if the service gets killed for some reason, onDestroy() is not called and I don’t have a chance to send a pause or shutdown broadcast so that the record button turns off. Result: the button stays red whereas recording has stopped.

This is some of the worst thing that can happen.

Why? The user takes a look at his home screen, he/she sees the red button and thinks recording is still being performed.

It’s not like with music playback, where the user can notice when music stops playing through the headphones… With recording, you don’t hear nothing if it stops.

I can understand the need for the system to kill services. I’m fine with that. I don’t need the service to get restarted and all that.

But I need to update the widget if the service shuts down, so that the user is not misled, thinking that his interview/concert/rehearsal/memo is still being recorded, while it’s not.

So how can I update the widget quickly if the service gets killed?

  • 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-23T05:32:39+00:00Added an answer on May 23, 2026 at 5:32 am

    I have found what I consider to be an answer to my own question.

    I return START_STICKY from onStartCommand() in my service.

    If I manually kill the service from DDMS, I get this in logcat:

    I/ActivityManager( 2500): Process com.foo.bar (pid 21874) has died.
    W/ActivityManager( 2500): Scheduling restart of crashed service com.foo.bar/.FooBarService in 5000ms
    

    And a few seconds later:

    I/ActivityManager( 2500): Start proc com.foo.bar for service com.foo.bar/.FooBarService: pid=22036 uid=10107 gids={1015, 3003} 
    

    The service does restart, and that allows me to send a broadcast from onStartCommand() to indicate that the audio engine is paused (I don’t resume recording automatically).

    The widget provider reacts to this broadcast and updates the widget appropriately.

    This works on Froyo and solves my problem: the user is not misled when looking at the widget. Recording stopped because the engine crashed, and the widget reflects this.

    It’s not bullet-proof, as it relies on the system restarting the service automatically, but I think that’s quite safe.

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

Sidebar

Related Questions

I have a web app(jsp/servlets) which allows users to download audio files and play
I currently have 3 ways to play audio within my app: Using AudioServicesPlaySystemSound for
Let us say I have an audio iPhone app which takes input from the
Is it possible to have an App (running iOS4 on hardware supporting multi-tasking) which
I have an app with callbacks for recording and playing audio. From the recording
I have an app in which records audio files. User can specify length of
I have an audio recording app in Windows Phone 7. The app allows a
I have an app which allows user to import media (videos, photos, audio) which
Possible Duplicate: Delay in Recording using avaudiorecorder I am running an app on Xcode4
I have been using the code in http://opensebj.blogspot.com/2009/04/naudio-tutorial-5-recording-audio.html to record audio. Basically this code:

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.