执行code,当用户改变在Android的静音模式 [英] Execute code when user changes to silent mode in Android

查看:76
本文介绍了执行code,当用户改变在Android的静音模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的服务。在该服务的用户更改为静音模式,即只要用户更改到静音模式,我的code需要得到执行时,我的code应该得到执行。

I'm using a service. In that service my code should get executed when the user changes to silent mode, i.e. as soon as the user changes to silent mode, my code needs to get executed.

我怎样才能做到这一点?

How can I do this?

推荐答案

您不想使用的服务。相反,你要使用 BroadcastReciever 的过滤器的android.media。 RINGER_MODE_CHANGED意图。

You don't want use a service. Instead you want to use a BroadcastReciever that filters for the android.media.RINGER_MODE_CHANGED Intent.

您可能想看看这项目因为它涉及的是手机被灭口。它可能有一些源$ C ​​$ C,这将是对你有用。

You might want to take a look at this project as it deals with the phone being silenced. It probably has some source code that will be useful to you.

这篇关于执行code,当用户改变在Android的静音模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆