AlarmManager只播放默认铃声
我正在使用AlarmManager和PendentIntent创建一个警报。警报起作用,并在正确的时间触发。不幸的是,无论我选择哪种铃声,它总是播放默认的铃声。这是我的代码:
public void setAlarm() {
Cursor cursor = dataBaseHelper.showSpecificTableData(DBFields.TABLE_OF_ALARMS, DBFields.ALARM_STATUS, "On");
cursor.moveToLast();
String alpha[] = cursor.getString(cursor.getColumnIndex(DBFields.ALARM_TIME)).split(":");
calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(alpha[0]));
calendar.set(Calendar.MINUTE, Integer.parseInt(alpha[1]));
calendar.set(Calendar.SECOND, 0);
Intent intent = new Intent(AddAlarm.this, AlarmReceiver.class);
intent.putExtra("AlarmTone", cursor.getString(cursor.getColumnIndex(DBFields.ALARM_TONE)));
intent.putExtra("AlarmId", cursor.getInt(cursor.getColumnIndex(DBFields.ALARM_ID)));
intent.putExtra("AlarmName", cursor.getString(cursor.getColumnIndex(DBFields.ALARM_NAME)));
intent.putExtra("AlarmTime", cursor.getString(cursor.getColumnIndex(DBFields.ALARM_TIME)));
pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),
100,
intent,
FLAG_UPDATE_CURRENT);
alarmManager.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
}
我已经使用了调试器,并且知道正确的铃声被作为“ AlarmTone”额外的。
知道为什么选定的铃声不玩
I'm creating an alarm using AlarmManager and PendingIntent. The alarm works and is triggered at the correct time. Unfortunately, it always plays the default ringtone, regardless of what ringtone I have selected. This is my code:
public void setAlarm() {
Cursor cursor = dataBaseHelper.showSpecificTableData(DBFields.TABLE_OF_ALARMS, DBFields.ALARM_STATUS, "On");
cursor.moveToLast();
String alpha[] = cursor.getString(cursor.getColumnIndex(DBFields.ALARM_TIME)).split(":");
calendar.set(Calendar.HOUR_OF_DAY, Integer.parseInt(alpha[0]));
calendar.set(Calendar.MINUTE, Integer.parseInt(alpha[1]));
calendar.set(Calendar.SECOND, 0);
Intent intent = new Intent(AddAlarm.this, AlarmReceiver.class);
intent.putExtra("AlarmTone", cursor.getString(cursor.getColumnIndex(DBFields.ALARM_TONE)));
intent.putExtra("AlarmId", cursor.getInt(cursor.getColumnIndex(DBFields.ALARM_ID)));
intent.putExtra("AlarmName", cursor.getString(cursor.getColumnIndex(DBFields.ALARM_NAME)));
intent.putExtra("AlarmTime", cursor.getString(cursor.getColumnIndex(DBFields.ALARM_TIME)));
pendingIntent = PendingIntent.getBroadcast(getApplicationContext(),
100,
intent,
FLAG_UPDATE_CURRENT);
alarmManager.setExact(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
}
I have used debugger and I know that the correct ringtone is put into the Intent as an "AlarmTone" extra.
Any idea why the selected ringtone isn't playing
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论