gpt4 book ai didi

java - 尝试使用通知

转载 作者:行者123 更新时间:2023-12-02 06:10:45 25 4
gpt4 key购买 nike

我正在尝试从我的 IntentService 中显示通知。

但没有任何显示:-(((((

public class CreditcheckService extends IntentService {
AlertDialog dialog;
public CreditcheckService() {
super("CreditcheckService");
}

@Override
protected void onHandleIntent(Intent intent) {
NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.icon)
.setContentTitle("My notification")
.setContentText("Hello World!");
NotificationManager mNotificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(999, mBuilder.build());
}

最佳答案

确定

我添加了以下内容:

    mBuilder.setContentIntent(PendingIntent.getActivity(getApplicationContext(), 0, new Intent(), 0));

而且它有效......

关于java - 尝试使用通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21914428/

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