Android obtains profiles and ringtones to realize vibration and ringtone reminder

When we want to remind users through ringing or vibration (similar to the mobile phone incoming call reminder interface), we need to consider the profile of the mobile phone itself. (at present, an oppo test mobile phone has found that I can still play the ringtone even if it is set to silent mode). In order to prevent the occurrence of "supernatural" events, it is still necessary to judge the profile before prompting, and specifically record the code.

1. Get mobile profiles:

There are three cases of ringermode: audiomanager.ringer_ MODE_ Normal (ring tone mode), audiomanager.ringer_ MODE_ Silent mode, audiomanager.ringer_ MODE_ Vibrate (vibration mode)

2. Get system ringtone URI:

3. Play / stop playing system ringtones

4. Turn on / off vibration [don't forget vibration system permission: < uses permission Android: name = "Android. Permission. Vibrate" / >]

5. Create profile change broadcast receiver listening

6. Unregister broadcast recipients when activity dies

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>