活动的副作用不再明显?
我编写了一个简单的应用程序,通过文本转语音来读取一页文本。它原则上可以工作,但现在我需要以对最终用户有意义的方式实现 onPause()、onResume() 等。
具体来说,关于 onPause() 我有 2 个选项:
- 暂停阅读,目的是 从左边的点继续。
- 正常继续,就好像 活动仍然可见。
第二种选择看起来更明智,因为如果这不是视觉活动,为什么要让视觉干扰打断讲话呢?
但是,我不确定在将 onPause() 实现为“不执行任何操作”函数时是否必须考虑其他系统范围的注意事项(“副作用”)。
除了当活动不再可见时调用 onPause() 之外,在决定是否停止文本转语音时还应该考虑其他事件或副作用吗?
I wrote a simple app reading a page of text via 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:
- Pause reading, with the intent to
continue exactly from point left. - 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
唯一想到的是系统是否内存不足。如果系统需要内存,则系统可以终止看不见的活动。我建议做的是使用长时间运行的服务而不是活动。让活动管理服务,但让服务处理文本的读取。如果您仍然想使用某个活动,我相信您可以设置一个设置,使杀死您看不见的活动成为最后的手段。
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.