2013-04-17 20 views
5

ビッグビュースタイルで通知を作成することはできません。サポートライブラリの問題?私のコードはEclipse(エラーなし)でOKですが、通知にはcontentTitle、ContentText、アイコンのみが表示されます...それだけです!私の通知に余分な行...何が間違っていますか?あなたの返事をありがとうございました。ここでは、コードだ...ビッグビュースタイルを設定できません

@Override 
protected void onMessage(Context arg0, Intent arg1) { 
    // TODO Auto-generated method stub 
    //Log.d("onMessage", String.valueOf(arg1)); 
    //Log.d("onMessage", "Receive a message"); 
    // Get the data from intent and send to notification bar 
    String message = arg1.getExtras().getString("message"); 
    generateNotification3(arg0, message); 
} 


private static void generateNotification3(Context context, String message) {  
    NotificationCompat.Builder mbuilder = 
      new NotificationCompat.Builder(context) 
      .setSmallIcon(R.drawable.ic_launcher) 
      .setContentTitle("lolo") 
      .setContentText("text") 
      .setDefaults(Notification.DEFAULT_ALL) // requires VIBRATE permission 
      /* 
      * Sets the big view "big text" style and supplies the 
      * text (the user's reminder message) that will be displayed 
      * in the detail area of the expanded notification. 
      * These calls are ignored by the support library for 
      * pre-4.1 devices. 
      */ 
      .setStyle(new NotificationCompat.BigTextStyle() 
        .bigText(message)); 

    // Creates an explicit intent for an Activity in your app 
     Intent resultIntent = new Intent(context, Fsa.class); 

     // The stack builder object will contain an artificial back stack for 
     // the 
     // started Activity. 
     // This ensures that navigating backward from the Activity leads out of 
     // your application to the Home screen. 
     TaskStackBuilder stackBuilder = TaskStackBuilder.create(context); 

     // Adds the back stack for the Intent (but not the Intent itself) 
     stackBuilder.addParentStack(Fsa.class); 

     // Adds the Intent that starts the Activity to the top of the stack 
     stackBuilder.addNextIntent(resultIntent); 
     PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, 
       PendingIntent.FLAG_UPDATE_CURRENT); 
     mbuilder.setContentIntent(resultPendingIntent); 

     NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); 

     // mId allows you to update the notification later on. 
     mNotificationManager.notify(100, mbuilder.build()); 

} 
+10

通知を手動で拡張しようとしましたか(左右に2本の指でタッチして下にドラッグ)しましたか?通知は、リストの一番上に表示される場合に自動的に展開されます。 – dsandler

+1

Gosh!あなたが正しい !!!優れた !!!!プログラム的に展開する方法はありますか?私は.setOngoing(真)を(上に)追加しましたが、拡張されていません...(最初のものは、ツールの開発のためにUSBに接続したときの最初の通知なので、もう一度私の友人ありがとう! – Kris88

+0

いいえ、プログラムで展開する方法はありません。その考え方は、拡張ポリシーがユーザーとシステムUIに依存するということです。アプリはデータを提供するだけです。 – dsandler

答えて

14

公式ドキュメントhereによると、「大きなビューは、通知は、通知の引き出しの一番上にあるときにたまたま、通知が展開されている場合のみ表示されたとき、またはユーザーが拡大ジェスチャー付きの通知 " だから、ビッグビュースタイルを持たせるためには、通知はリストの一番上に置くものとする。

それを行うには、あなたがあなたの通知を作成すると追加してください:

ユーザーが開かない場合は、それはそれはもちろん、(受信されたリストの一番上の位置に常に配置されますので
setPriority(Notification.PRIORITY_MAX) 

通知の引き出しや他の通知が最大優先度で到着した場合、あなたがまだトップにいることは保証されません)。

+0

これは、リストの先頭に移動することを保証するものではなく、ベストプラクティスにも違反します。この場合、P_MAXフラグは使用されません。また、これがまだ機能しない場合があります(例えば、進行中のイベントフラグ)。この質問はまだ有効であり、そのように開いています。 解決策がある場合は、投稿を編集してください。 – Japes

関連する問題