gpt4 book ai didi

java - 收到消息时通知如何工作

转载 作者:行者123 更新时间:2023-12-01 13:47:23 25 4
gpt4 key购买 nike

我正在使用应用程序来接收消息,但我想在接收消息时显示通知

请问工作怎么样

最佳答案

PendingIntent pi = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), Player.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP), PendingIntent.FLAG_UPDATE_CURRENT);
notification = new Notification();
notification.tickerText = "App Name";
notification.icon = R.drawable.icon;
notification.flags |= Notification.FLAG_ONGOING_EVENT;
try {
notification.setLatestEventInfo(getApplicationContext(), "App Name", "AppName~ ", pi);
} catch (Exception e) {

e.printStackTrace();
}
startForeground(01, notification);

关于java - 收到消息时通知如何工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20259767/

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