2017-02-18 2 views
0

Ich habe Suche und gefunden Lösung, aber diese Lösung zeigt nicht Multi-Line-Push-Benachrichtigung. Mein Code ist unten,Android Push-Benachrichtigung zeigt Text in einer Zeile

int id = (int) System.currentTimeMillis(); 

    Intent intent = new Intent(this, Activity.class); 
    Bundle bundle = new Bundle(); 
    bundle.putString("id", u_id); 
    intent.putExtras(bundle); 


    PendingIntent resultPendingIntent = 
      PendingIntent.getActivity(
        this, 
        0, 
        intent, 
        PendingIntent.FLAG_CANCEL_CURRENT 
      ); 

    NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
      this); 
    Notification notification = mBuilder.setSmallIcon(getNotificationIcon()).setTicker(getResources().getString(R.string.app_name)).setWhen(0) 
      .setAutoCancel(true) 
      .setContentTitle(getResources().getString(R.string.app_name)) 
      .setStyle(new NotificationCompat.BigTextStyle().bigText(messageBody)) 
      .setContentIntent(resultPendingIntent) 
      .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION)) 
      .setLargeIcon(BitmapFactory.decodeResource(getResources(), getNotificationIcon())) 
      .setContentText(messageBody).build(); 

    NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 
    notificationManager.notify(id, notification); 

Wie kann ich Mehrzeilentext in Push-Benachrichtigung zeigen?

+0

sehen dies .... http://stackoverflow.com/questions/22079663/how-to-apply-a-big-view-style-to-a-notification-using-parse-library –

Antwort

0
Intent intent = new Intent(this, target.class); 
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, 
      PendingIntent.FLAG_ONE_SHOT); 
     Bitmap image= BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher); 
    Uri defaultSoundUri= RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
    NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 
      .setSmallIcon(R.drawable.youricon) 
      .setContentTitle("Title") 
      .setLargeIcon(image) 
      .setContentText("Message") 
      .setAutoCancel(true) 
      .setSound(defaultSoundUri) 
      .setContentIntent(pendingIntent) 
      .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(bitmap).setSummaryText("multiline text")); 

    NotificationManager notificationManager = 
      (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); 

    notificationManager.notify(m/* ID of notification */, notificationBuilder.build()); 
Verwandte Themen