onPause 锁屏和来电的区别

发布于 2024-09-30 06:57:48 字数 165 浏览 0 评论 0原文

我正在开发一个音频应用程序。它在后台播放声音,我希望它在来电时关闭,但在屏幕锁定时不关闭。 我的第一次机会是在 onPause 上调用player.stop(),因为我认为当传入或其他应用程序在上面运行时它会起作用。 但我发现屏幕锁定也会调用这个 onPause 事件。

有机会了解该电话的原因吗?

I'm developing an audio application. It plays sounds in the background and I want it to turn off when an incoming call happens but not when the screen locks.
My first chance was to call player.stop() on onPause as I thought it will do the trick when incoming or other applications will run on top.
But I found that screen lock calls also this onPause event.

Is there any chance to get the cause of that calling?

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

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

发布评论

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

评论(1

孤蝉 2024-10-07 06:57:48

我相信这篇文章有您正在寻找的内容:
http://thinkandroid.wordpress。 com/2010/01/24/handling-screen-off-and-screen-on-intents/

有一些代码片段解释了如何处理屏幕关闭等问题。

希望对一些人有所帮助!

I believe this article has what you are looking for:
http://thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/

Has some snippets of code explaining how to handle if the screen turns off etc.

Hope that helps some!

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