2016-04-20 21 views
1

私は通知のために以下のコードを書いていますが、通知の通知とタイトルを見ることはできますが、テキストは表示されません。私は静的な価値を何度も試してみましたが、まだ何が問題になっていないのですか。事前に感謝してください。なぜアンドロイド通知テキストが表示されないのですか?

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()); 
} 

答えて

5

はあなたが私がチェックしてみましょう、あなたのnotificationBuilder

ドキュメント上ご返信用here

+0

感謝を.setContentText("Example")を忘れてしまったようです。 – Adarsh

+0

OMG ....私は重要なメソッドがありませんでした..あなたの答えをありがとう。 – Adarsh

関連する問題