android - Bad notification posté - ne Pouvait pas étendre RemoteViews pour: StatusBarNotification

Je suis en train de publier une notification avec une vue personnalisée dans la zone de notification à partir d'un IntentService, et d'obtenir le Couldn't expect RemoteView erreur.

Voici ce que je fais dans onCreate():

mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
icon = R.drawable.icon;
tickerText = "data upload in progress";
contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.notiflayout);
contentView.setImageViewResource(R.id.image, R.drawable.icon);
contentView.setTextViewText(R.id.text, "Hello");
contentView.setProgressBar(R.id.progressBar, 100, 10, false);
whatNext = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), starterActivity.class), 0);
notification = new Notification(icon, tickerText, System.currentTimeMillis());
notification.contentView = contentView;
notification.contentIntent = whatNext;

Je fais appel notify() de onHandleIntent() et l'annulation de la notifications dans onDestroy().

J'ai vérifié que ce code fonctionne de façon indépendante de l'app, qui n'a pas de IntentService. Faire cela dans un IntentService est en quelque sorte donner de la difficulté.

Quelqu'un pourrait-il expliquer qu'est-ce que je fais de mal?

Merci!

InformationsquelleAutor Chaitanya | 2011-06-02