android内置闹钟铃声覆盖短信铃声
先生,请帮我做节目。如果用户收到带有关键字的消息,我计划发出警报。如何强制应用程序使用闹钟(闹钟中始终使用的类型),即使它不是由用户设置的,并使用它来代替接收消息时使用的音调。因为当我尝试运行该程序时,我会听到收到短信时的通知音和默认铃声。提前谢谢android内置闹钟铃声覆盖短信铃声,android,alarm,Android,Alarm,先生,请帮我做节目。如果用户收到带有关键字的消息,我计划发出警报。如何强制应用程序使用闹钟(闹钟中始终使用的类型),即使它不是由用户设置的,并使用它来代替接收消息时使用的音调。因为当我尝试运行该程序时,我会听到收到短信时的通知音和默认铃声。提前谢谢 for (SmsMessage msg : messages) { if (msg.getMessageBody().contains("alert")) { Uri alert = RingtoneMana
for (SmsMessage msg : messages) {
if (msg.getMessageBody().contains("alert")) {
Uri alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
if(alert == null){
// alert is null, using backup
alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
if(alert == null){
// alert backup is null, using 2nd backup
alert = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
}
}
Ringtone r = RingtoneManager.getRingtone(context.getApplicationContext(), alert);
r.play();
Toast.makeText(context.getApplicationContext(), "alarm started", Toast.LENGTH_LONG).show();
}//end if
}//end for
您唯一能做的就是将清单中的意图过滤器的优先级保持在最大,这类似于
<receiver android:name="com.missed.reciever.SmsReceiver" >
<intent-filter android:priority="2147483647" >
这将做的是,你将收到默认和android消息应用程序之前的消息,然后你可以阅读短信,并将其标记为已读
这基本上就是像GOSM这样的应用程序所做的