活动的副作用不再明显?

发布于 2024-11-02 21:23:36 字数 370 浏览 6 评论 0原文

我编写了一个简单的应用程序,通过文本转语音来读取一页文本。它原则上可以工作,但现在我需要以对最终用户有意义的方式实现 onPause()、onResume() 等。

具体来说,关于 onPause() 我有 2 个选项:

  1. 暂停阅读,目的是 从左边的点继续。
  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:

  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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独孤求败 2024-11-09 21:23:36

唯一想到的是系统是否内存不足。如果系统需要内存,则系统可以终止看不见的活动。我建议做的是使用长时间运行的服务而不是活动。让活动管理服务,但让服务处理文本的读取。如果您仍然想使用某个活动,我相信您可以设置一个设置,使杀死您看不见的活动成为最后的手段。

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.

触ぅ动初心 2024-11-09 21:23:36

如果您被电话(或人们听到的任何东西)打扰,您就不会想继续发出声音。

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文