Reputation: 2810
I am working on a Android Project that control Android Device through Speech. For that I am using speech Recognition Service of Google.
Here I have created a service for handling Speech recognition.
But what is going is that after some time this service gets stopped automatically and my device stops responding to the speech of the user.
Then little seconds later, it starts responding again.
So my question here is that how can I stop my service from being destroyed automatically and if possible is there any trick to call my broadcast receiver whenever my service stops? So that I can create my Broadcast receiver for handling service destruction.
And how can I also stop my device from ringing beep tune when Speak recognition Service going on?
Upvotes: 2
Views: 4211
Reputation: 517
You have to start your Service
with startForeground()
. You have to pass it a Notification
that will be placed in the notification bar permanently. This make your Service
unstoppable from the system.
As always refer to android documentation for more details.
http://developer.android.com/guide/components/services.html#Foreground
Upvotes: 6