2016-08-10 5 views
0

通知のカスタムタイトルを設定したいのですが、常にプロジェクト名を小文字に設定しています。以下は私のコードです。このコードで何が間違っていますか?親切に私を助けてください。NotificationManagerのタイトルを設定するには?

NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) 
      .setSmallIcon(R.mipmap.ic_launcher) 
      .setContentTitle("My Notification") 
      .setContentText(messageBody) 
      .setAutoCancel(true) 
      .setSound(defaultSoundUri) 
      .setContentIntent(pendingIntent); 

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

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

通知のタイトルを変更する場合は、 –

+0

"My Notification"は小文字で表示したいと思っていますが、私のアプリケーション名は小文字で表示されます。 @SohailZahid – Furqan

答えて

0

ここではハード値を使用しています.setContentTitle(getResources().getString(R.string.app_name))なぜあなたは同じタイトルを常に狙っているのですか?

<string name="app_name">Your App Name</string> 

一部の変数の動的値を使用して変更することができます。

+0

"My Notification"を見たいと思っていますが、プロジェクト名が表示されています。 – Furqan

+0

ありがとうございます。 @SohailZahid – Furqan

0

あなたはnotif titleを"My Notification"と設定しています。それをあなたのアプリ名に変更してください。

+0

私は "My Notification"を見たいと思っていますが、プロジェクト名が表示されています。@UgurcanYildirim – Furqan

+0

他の場所に変更してはいけません。 –

+0

これで動作します。私はただプロジェクトを再開します。申し訳ありませんが私の間違いでした。 – Furqan

関連する問題