开发者

Android Beep or Light without a Notification object?

开发者 https://www.devze.com 2023-02-16 14:01 出处:网络
Is there any way to start a beep (yes, a beep sound) or turn on the light of a device without a Notification instance?

Is there any way to start a beep (yes, a beep sound) or turn on the light of a device without a Notification instance?

W开发者_开发知识库ith a notification it's easy as shown here: http://developer.android.com/guide/topics/ui/notifiers/notifications.html

This is possible to do with iPhone API, and I need the exaclty same behavior on android.


I don't think thats possible. You will have to stick with the notify and cancel workaround. Just as an example see the TweetDeck android app. In the column settings, there are options on top that say : Notify, Light, Sound, Vibrate. You can select either of Light, Sound and Vibrate or a combination of these, however, they all need the notify to be selected.


You can use the media player and play an audio file. http://developer.android.com/reference/android/media/MediaPlayer.html


for a beep, you can either use:

  1. ToneGenerator- generates frequencies and DTMF-like tones for a chosen interval http://developer.android.com/reference/android/media/ToneGenerator.html

  2. RingtoneManager - allows you to obtain and play the default ringtone for notifications (without using a notification). http://developer.android.com/reference/android/media/RingtoneManager.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号