Ya hay varios hilos sobre cómo hacer diseños personalizados en la barra de notificaciones. El problema es que me falta algo simple.Actualización de la barra de progreso en el área de notificación
Tengo un custom_notification_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="3dip"
>
<TextView android:id="@+id/text"
android:text="Uploading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
/>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:max="0"
android:progress="0"
android:layout_marginLeft="10dip"
android:id="@+id/progressBar"
/>
</LinearLayout>
también tengo algo de código de prueba que crea la notificación, que funciona y muestra la barra de progreso.
NotificationManager mManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon, title, System.currentTimeMillis());
RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.custom_notification_layout);
contentView.setProgressBar(R.id.progressBar, 10, 0, false);
contentView.setTextViewText(R.id.text, text);
notification.contentView = contentView;
Intent notificationIntent = new Intent(context, NotificationHandler.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.contentIntent = contentIntent;
mManager.notify(APPID, notification);
Finalmente trato de actualizar la barra de progreso, que no funciona.
contentView.setProgressBar(R.id.progressBar, 10, 5, false);
¿Cuál es el secreto para actualizar realmente la notificación?
Ver posible duplicado: http://stackoverflow.com/questions/2689729/progress-bar-in-notification-bar –