我正在实现一个应用程序,如果可用,我必须在其中显示警报信息(日期、时间..)。有人知道如何访问警报信息吗?非常感谢
问问题
1449 次
2 回答
3
结果:最后,我可以使用上面好奇的答案来检索警报信息。此外,当我在 /packages/apps/ 中探索 Deskclock 应用程序时,我发现了另一种获取下一个警报格式的方法(我使用这种方式在我的 LockScreen 上显示警报信息,因为它比 Curious 的更简单:))
String nextAlarm = Settings.System.getString(getContentResolver(),
Settings.System.NEXT_ALARM_FORMATTED);
if(TextUtils.isEmpty(nextAlarm) {
Log.v(TAG, "nextAlarm is empty");
} else {
Log.v(TAG, "nextAlarm is :" + nextAlarm);
}
下一个报警格式如下:
Sat 09:00
缺点是它只能在系统环境中运行(你必须将它们嵌入到 Android 源 -> 构建它并通过图像文件运行)。
于 2012-12-10T09:45:38.957 回答
2
尝试这样的事情
final String tag_alarm = "tag_alarm";
Uri uri = Uri.parse("content://com.android.alarmclock/alarm")
Cursor c = getContentResolver().query(uri, null, null, null, null);
Log.i(tag_alarm, "no of records are" + c.getCount());
Log.i(tag_alarm, "no of columns are" + c.getColumnCount());
if (c != null) {
String names[] = c.getColumnNames();
for (String temp : names) {
System.out.println(temp);
}
if (c.moveToFirst()) {
do {
for (int j = 0; j < c.getColumnCount(); j++) {
Log.i(tag_alarm, c.getColumnName(j);
+ " which has value " + c.getString(j));
}
} while (c.moveToNext());
}
}
于 2012-12-07T08:00:38.987 回答