2013-04-29 42 views
4

我正在使用v13支持庫。我使用通知構建器和.setProgress構建了一個進度通知。它在4.2.2設備上工作得很好,但在2.3.5上沒有顯示。NotificationBuilder.setProgress在2.3.5上不執行任何操作

這是正常的行爲?

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

mBuilder = new NotificationCompat.Builder(this); 

mBuilder.setContentTitle("Photo Upload") 
      .setContentText("Upload in progress") 
      .setSmallIcon(R.drawable.ic_action_upload) 
      .setOngoing(true); 

. 
. 

mBuilder.setProgress(100, prog, false); 
mNotifyManager.notify(sNotificationID, mBuilder.build()); 
+0

有關於此的任何消息嗎? – 2015-07-01 21:36:48

回答

1

似乎不喜歡薑餅(以下)不支持,它也沒有記錄。
下面是從它創建的Notification實例的支持庫的實際代碼:

static class NotificationCompatImplBase implements NotificationCompatImpl { 
    public Notification build(Builder b) { 
     Notification result = (Notification) b.mNotification; 
     result.setLatestEventInfo(b.mContext, b.mContentTitle, 
       b.mContentText, b.mContentIntent); 
     // translate high priority requests into legacy flag 
     if (b.mPriority > PRIORITY_DEFAULT) { 
      result.flags |= FLAG_HIGH_PRIORITY; 
     } 
     return result; 
    } 
} 

唯一可行的辦法是使用自定義RemoteView。您可能需要查看Android源代碼以獲取示例進度通知佈局。

0

它的工作原理4.2.2設備上就好了,但沒有2.3.5所示

的Android 1.x和2.x(尤其是薑餅)從Notification contentIntent需要(也空)。因此,創建空的操作是這樣的:

PendingIntent action = PendingIntent.getBroadcast(<context>, 0, 
           new Intent(), PendingIntent.FLAG_UPDATE_CURRENT); 
... 
mBuilder.setContentIntent(action); 

而現在它應該工作。

+1

Actualy這使得通知顯示,但進度條不工作,因爲該版本。 – 2013-08-26 05:59:57

相關問題