0
私はカスタム通知にこのコードを使用しています。問題は、文字列内のテキスト全体が1行で表示されていることです。通知バーの操作ボタンが表示されません
private void showNotification(String msg){
//Creating a notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setSmallIcon(R.drawable.ic_alert);
builder.setContentTitle("Alert");
builder.setContentText(msg);
builder.setAutoCancel(false);
builder.setPriority(NotificationCompat.PRIORITY_HIGH);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.google.com"));
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
builder.setContentIntent(pendingIntent);
//builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher));
builder.addAction(R.drawable.ic_call, "Accept", pendingIntent).build();
// builder.addAction(R.drawable.ic_alert, "Reject", pendingIntent).build();
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());
}
私は.........コードに次の行が、まだ同じ問題を追加したNotification.Builder =新しいNotification.Builder(この)釜; ........ buil.setStyle(new Notification.BigTextStyle() .bigText(msg)); .........新しいNotificationCompat.Action(R.drawable.ic_call、 "CALL"、pendingIntent); –
あなたは[this](https://developer.android.com/reference/android/support/v4/app/NotificationCompat.Builder.html#addAction(android.support.v4.app.NotificationCompat.Action))メソッドを呼び出しましたか?あなたの 'NotificationCompat.Builder'に? –
setStyleはNotificationクラスによって呼び出されます。Notification.Builder buil = new Notification.Builder(this); –