2016-04-20 19 views
1

Ich habe folgenden Code für die Benachrichtigung geschrieben, kann ich Benachrichtigung und Titel der Benachrichtigung sehen, aber Text ist nicht sichtbar. Ich habe viele Male mit statischem Wert versucht, aber immer noch nicht, was das Problem ist. Bitte hilf mir, danke im Voraus.Warum Android Benachrichtigungstext nicht angezeigt wird?

private void messagenotification(String msg, String nextid) { 


    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0); 
    SharedPreferences.Editor editor = settings.edit(); 
    editor.putString("id", nextid ).apply(); 

    Intent intent = new Intent(this, NextActivity.class); 
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
    PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, 
      PendingIntent.FLAG_ONE_SHOT); 

    Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); 
    NotificationCompat.Builder notificationBuilder = (NotificationCompat.Builder) new NotificationCompat.Builder(this) 
      .setSmallIcon(R.mipmap.blue) 
      .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.blue)) 
      .setContentTitle("Chat") 
      .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)) 
      .setAutoCancel(true) 
      .setSound(defaultSoundUri) 
      .setContentIntent(pendingIntent); 



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

    notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); 
} 

Antwort

5

Es scheint, dass Sie .setContentText("Example") auf notificationBuilder

Dokumentation here

+0

Vielen Dank für Ihre Antwort vergessen haben, lassen Sie mich überprüfen. – Adarsh

+0

OMG .... mir fehlte die wichtige Methode .. Danke für deine Antwort. – Adarsh

Verwandte Themen