gpt4 book ai didi

android-notifications - 没有从 NotificationCompat.Builder 收到通知

转载 作者:行者123 更新时间:2023-12-04 22:33:54 24 4
gpt4 key购买 nike

我想通过构建器方法生成一个显示进度的通知栏,但我不知道我哪里出错了。如果有人能告诉我哪里出错并帮助我,我将不胜感激.....

public class DownloadReceiver extends ResultReceiver{
private final static String TAG = "DownloadReceiver";
public Context context;
public DownloadReceiver(Handler handler,Context context) {
super(handler);
this.context = context;
Log.d(TAG,handler.getLooper().getThread().getName());
}

@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
super.onReceiveResult(resultCode, resultData);
Log.d(TAG,"in download receiver");

NotificationManager notificationManager = (NotificationManager) context.getSystemService(Service.NOTIFICATION_SERVICE);
Intent notifyIntent = new Intent(android.content.Intent.ACTION_VIEW,Uri.parse("http://www.android.com"));
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notifyIntent, 0);

if(resultCode == DownloadService.COMPLETED){
Log.d(TAG,resultCode + "");
Builder notificationBuilder = new NotificationCompat.Builder(context)
.setProgress(100, 20, false)
.addAction(R.drawable.ic_action_search, "title", pendingIntent)
.setWhen(System.currentTimeMillis());
// notification.flags = Notification.FLAG_ONGOING_EVENT;
// notification.setLatestEventInfo(context, "contentTitle", "contentText", pendingIntent);
notificationManager.notify(50, notificationBuilder.build());
}else if(resultCode == DownloadService.ALLCOMPLETED){

}
}
}

最佳答案

我刚刚才需要处理这个,我的解决方案是您必须添加通知图像
.setSmallIcon(R.drawable.launcher)
否则它不会显示任何内容。旧的通知方法不需要您自己设置,因为它会默认为应用程序的图标。

关于android-notifications - 没有从 NotificationCompat.Builder 收到通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12972991/

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