On Sat, Oct 16, 2010 at 12:17 PM, kronos <[email protected]> wrote:
> My service uses Text-to-speech service, and in the logcat output, I > can see the text-to-speech service shutting down when the phone goes > to sleep. My service then enters a state where it uses up cpu but > does nothing. > Using CPU to do nothing seems like a bad thing. > How can I set setForground(id, notificaiton) on the text-to-speech > service so that it won't shutdown when the phone goes to sleep ? > setForeground, (a) does nothing as of 2.0, and (b) has nothing to do with going to sleep. The API to use as of 2.0 is startForeground(). Either way, it just tells the system that the user is aware of what your service is doing, so it should try harder to keep it in memory. > I guess I need a feature similar to the Navigation Activity where the > phone speaks even if it is sleeping. > I don't know what Navigation Activity is, but you use a partial wake lock to keep the CPU running even if the screen is off. You can use this anywhere: activity, service, etc. Now your original message said you got an error about a timeout executing your service. If this is indeed the case, then you have a bug in your code where you are blocking the main thread of the process so it can't respond to messages from the system. After the timeout happens, you should be able to see the stacks with "adb shell dumpsys /data/anr/traces.txt" -- Dianne Hackborn Android framework engineer [email protected] Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

