1500字范文,内容丰富有趣,写作好帮手!
1500字范文 > android 前台服务自定义布局不显示_Android前台服务通知未显示

android 前台服务自定义布局不显示_Android前台服务通知未显示

时间:2020-05-18 14:35:45

相关推荐

android 前台服务自定义布局不显示_Android前台服务通知未显示

我正在尝试启动前台服务.我收到通知,该服务确实启动但通知始终被抑制.我仔细检查了应用是否允许在我的设备上的应用信息中显示通知.这是我的代码:

private void showNotification() {

Intent notificationIntent = new Intent(this, MainActivity.class);

notificationIntent.setAction(Constants.ACTION.MAIN_ACTION);

notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK

| Intent.FLAG_ACTIVITY_CLEAR_TASK);

PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,

notificationIntent, 0);

Bitmap icon = BitmapFactory.decodeResource(getResources(),

R.mipmap.ic_launcher);

Notification notification = new NotificationCompat.Builder(getApplicationContext())

.setContentTitle("Revel Is Running")

.setTicker("Revel Is Running")

.setContentText("Click to stop")

.setSmallIcon(R.mipmap.ic_launcher)

//.setLargeIcon(Bitmap.createScaledBitmap(icon, 128, 128, false))

.setContentIntent(pendingIntent)

.setOngoing(true).build();

startForeground(Constants.FOREGROUND_SERVICE,

notification);

Log.e(TAG,"notification shown");

}

这是我在关系中看到的唯一错误:

06-20 12:26:43.635 895-930 /? E / NotificationService:按用户请求抑制来自包的通知.

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。