Нажать тревожное сообщение в AndroidAndroid

Форум для тех, кто программирует под Android
Ответить
Anonymous
 Нажать тревожное сообщение в Android

Сообщение Anonymous »


I'm developing an Android app and I have a question.

I receive an alarm while developing a push alarm, but I want to customize the icon as shown in the image below. What should I do?

enter image description here

my app.... enter image description here

my code...

private void sendNotification(String title, String body) { NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { NotificationChannel channel = new NotificationChannel(CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT); channel.setDescription(CHANNEL_DESCRIPTION); channel.enableLights(true); channel.setLightColor(Color.BLUE); channel.enableVibration(true); notificationManager.createNotificationChannel(channel); } // 알림을 클릭했을 때 앱으로 이동하기 위한 Intent 설정 Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); // 기존의 액티비티 스택을 모두 제거하고 새로운 액티비티를 생성 PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE ); // Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.todaysun_logo_notification); // int newWidth = 100; // 조절할 새로운 이미지의 폭 // int newHeight = 100; // 조절할 새로운 이미지의 높이 // boolean filter = true; // 이미지를 부드럽게 할지 여부 // Bitmap scaledLargeIcon = Bitmap.createScaledBitmap(largeIcon, newWidth, newHeight, filter); // Bitmap largeIcon = BitmapFactory.decodeResource(getResources(), R.mipmap.todaysun_logo); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this, CHANNEL_ID) .setSmallIcon(R.drawable.todaysun_notification2) .setContentTitle(Html.fromHtml("" + title+ "")) .setContentText(body) .setAutoCancel(true) .setContentIntent(pendingIntent) .setStyle(new NotificationCompat.BigTextStyle().bigText(body)) // 알림 메세지를 ... 아닌 전체 받을 수 있도록 처리 .setColor(Color.BLUE) // .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(largeIcon).bigLargeIcon(null)) .setLargeIcon(largeIcon); ; notificationManager.notify(0, notificationBuilder.build()); } enter image description here


Источник: https://stackoverflow.com/questions/780 ... in-android
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «Android»