Android 显示活动顶部,如果应用程序打开,如果收到通知
如果应用程序已经打开,我想在活动顶部显示通知。没有通知声:)Android 显示活动顶部,如果应用程序打开,如果收到通知,android,push-notification,Android,Push Notification,如果应用程序已经打开,我想在活动顶部显示通知。没有通知声:) 嗨,如果应用程序没有打开,我希望它在正常通知时出现并发出声音。如果应用程序被打开,我想弹出通知,没有声音..请帮助我。 这是我的密码 NotificationCompat.Builder b = new NotificationCompat.Builder(getApplicationContext()); b.setAutoCancel(true) .setDefaults(Noti
嗨,如果应用程序没有打开,我希望它在正常通知时出现并发出声音。如果应用程序被打开,我想弹出通知,没有声音..请帮助我。 这是我的密码
NotificationCompat.Builder b = new NotificationCompat.Builder(getApplicationContext());
b.setAutoCancel(true)
.setDefaults(Notification.DEFAULT_ALL)
.setWhen(System.currentTimeMillis())
.setSmallIcon(R.drawable.welcome)
.setTicker("" + getResources().getString(R.string.notif))
.setContentTitle(message + " : " + hican)
.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND)
.setContentIntent(contentIntent)
.setContentInfo("ABC")
.setStyle(new NotificationCompat.BigTextStyle()
.bigText(icerik));
NotificationManager notificationManager = (NotificationManager) getApplicationContext().getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(1, b.build());
如果您不需要通知声音,只需删除行
中的notification.DEFAULT\u sound
。设置默认值(notification.DEFAULT\u LIGHTS | notification.DEFAULT\u sound)
将其写成.setDefaults(Notification.DEFAULT\u LIGHTS)
如果您想显示弹出式通知(headup notification
),请尝试将通知优先级设置为notification.priority\u HIGH
或notification.priority\u MAX
添加这一行
.setPriority(Notification.PRIORITY\u HIGH)
如果您不想要通知声音,只需删除行中的通知.DEFAULT\u sound
。setDefaults(Notification.DEFAULT\u LIGHTS | Notification.DEFAULT\u sound)
将其写成.setDefaults(Notification.DEFAULT\u LIGHTS)
如果您想显示弹出式通知(headup notification
),请尝试将通知优先级设置为notification.priority\u HIGH
或notification.priority\u MAX
添加这一行
.setPriority(Notification.PRIORITY\u HIGH)
Hi,如果应用程序未打开,我希望它在正常通知时出现并发出声音。如果应用程序打开,我希望弹出通知,没有声音..你知道Whatsapp应用程序。喜欢。WhatsApp没有欢迎通知*!!!你到底想要什么???嗨,如果应用程序没有打开,我希望它在正常通知时出现并发出声音。如果应用程序打开,我希望弹出通知,没有声音..你知道Whatsapp应用程序。喜欢。WhatsApp没有欢迎通知*!!!你到底想要什么???