gpt4 book ai didi

android - Android 中的自定义提醒弹出 View

转载 作者:行者123 更新时间:2023-11-30 03:40:12 25 4
gpt4 key购买 nike

我正在处理日历事件提醒。 android 中没有 native 日历事件提醒,因此用户安装不同的日历应用程序。现在这些应用程序可以在提醒事件上有所不同,比如可以显示提醒通知。现在我希望我在这些事件日历应用程序中以编程方式设置一个事件,并且在到达时间时不显示任何通知,而是会显示一条弹出消息,并带有类似声音的警报。那时我使用了来自 site 的代码.它可以正常工作,但会以通知的形式显示提醒。

代码如下:

接收时:

  void doReminderWork(Intent intent) {


Log.d("ReminderService", "Doing work.");
Long rowId = intent.getExtras().getLong(RemindersDbAdapter.KEY_ROWID);

NotificationManager mgr = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);

Intent notificationIntent = new Intent(this, ReminderEditActivity.class);
notificationIntent.putExtra(RemindersDbAdapter.KEY_ROWID, rowId);

PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT);

Notification note=new Notification(android.R.drawable.stat_sys_warning, getString(R.string.notify_new_task_message), System.currentTimeMillis());
note.setLatestEventInfo(this, getString(R.string.notify_new_task_title), getString(R.string.notify_new_task_message), pi);
note.defaults |= Notification.DEFAULT_SOUND;
note.flags |= Notification.FLAG_AUTO_CANCEL;


int id = (int)((long)rowId);
mgr.notify(id, note);


}

现在我想显示一个弹出界面,就像闹钟一样有声音,所以这怎么可能。

最佳答案

在您的 doReminderWork() 中,您可以启动对话式 Activity ,而不是显示通知。

关于android - Android 中的自定义提醒弹出 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15873225/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com