Android 音频管理器方法导致强制关闭

发布于 2024-09-06 03:16:21 字数 255 浏览 2 评论 0原文

对此感到陌生,并且对为什么调用以下方法会创建强制关闭感到有点困惑:

AudioManager myaudiomanager;

public void toggleSilent()
{
  myaudiomanager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}

我没有看到任何明显的错误,并且我已向有关音频管理器的清单添加了权限。

有人能进一步指导我吗?

New to this and a bit confused as to why calling the following method creates a force close:

AudioManager myaudiomanager;

public void toggleSilent()
{
  myaudiomanager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
}

I don't see any blatant errors and I have added permissions to the manifest regarding the audio manager.

Anyone able to direct me further?

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

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

发布评论

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

评论(2

谜泪 2024-09-13 03:16:21

该对象从未首先被创建。尝试一下。

myaudiomanager = new AudioManager();
// Not sure what parameters are needed but the documentation in the audiomanager tag has it.

The object is never created first of all. Try that.

myaudiomanager = new AudioManager();
// Not sure what parameters are needed but the documentation in the audiomanager tag has it.
怀里藏娇 2024-09-13 03:16:21

如果您发布了 ADB 日志,可能会有所帮助。

强制关闭通常意味着您的主线程没有响应,或者更具体地说,没有在 Android 的分配时间内响应。我发现很难相信对 AudioManager 的调用会导致 FC。

If you posted the ADB log that might help..

A force close usually means your main thread is not responding, or more specifically not withing the alotted time of Android. I find it hard to believe a call into the AudioManager is causing a FC..

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