开发者

Side effects of activity no longer visible?

I wrote a simple app reading a page of text vi开发者_运维知识库a text-to-speech. It works in principle but now I need to implement onPause(), onResume() etc. in a way that would make sense to the end user.

Specifically about onPause() I have 2 options:

  1. Pause reading, with the intent to continue exactly from point left.
  2. Continue normally, as if the activity is still visible.

The 2nd option looks more sensible because if it's not a visual activity, why let visual disturbances interrupt speech?

However, I am not sure whether there are other system-wide considerations ("side-effects") that I must be taking into account when implementing onPause() as a "do nothing" function.

Aside from onPause() being called when an activity is no longer visible, are there other events or side-effect that I should take into consideration when deciding whether to stop or not to stop text-to-speech?


The only thing that comes to mind is if the system runs out of memory. Activities that are out of sight can be killed by the system if it needs the memory. What I'd suggest doing is using a long running service rather than an Activity. Let the activity manage the service but let the service handle the reading of text. If you still want to use an Activity, I believe there is a setting you can set to make killing your unseen Activity a last resort.


If you were being interrupted by the phone (or anything people listen to), you wouldn't want to keep producing sound.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜