我正在写一个应用程序,通知用户非常时间敏感的信息,我认为他们中的很多人会想使用手机铃声,而不是只是短的通知声音。我通过在我的PreferenceScreen中设置android:ringtoneType="all"
来启用此功能,并且它工作的很好,除了选择手机铃声时,它会一直播放FOREVER,直到用户触摸通知栏为止......我如何在30秒后关闭它或那么,不取消通知?如何在30秒后停止android通知铃声?
继承人,我用我的C2DM接收器代码:
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notif = new Notification(....)
....
String ringtone = PreferenceManager.getDefaultSharedPreferences(context).getString("ringtone", "");
notif.sound = Uri.parse(ringtone);
notif.audioStreamType = AudioManager.STREAM_NOTIFICATION;
nm.notify(1, notif);
offtopic:C2DM已弃用使用Google Clound Messaging(GCM) – 2012-07-19 14:03:06