2016-06-01 13 views
0

Ich arbeite derzeit an einer Android-App. Ich muss einen Benutzer benachrichtigen, dass er an einer Stelle in der normalen Benachrichtigung angekommen ist, und wenn die Benachrichtigung erweitert wird, werden zusätzliche Informationen angezeigt. Die üblichen :)BigContentView scheint nicht aktualisiert zu werden

Ich benutze 2 verschiedene remoteViews, eine zum Festlegen der ContentView und eine zum Festlegen der BigContentView.

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

    // build notification 
    NotificationCompat.Builder mBuilder = 
      new NotificationCompat.Builder(context) 
        .setSmallIcon(R.mipmap.ic_launcher) 
        .setContentIntent(notificationPendingIntent) 
        .setColor(Color.CYAN) 
        .setPriority(NotificationCompat.PRIORITY_MAX) 
        .setAutoCancel(true) 
        .setContentTitle("Content Title") 
        .setContentText("Content Text"); 

    int NOTIFICATION_ID = 1; 

    RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.remoteview_notification); 
    rv.setImageViewResource(R.id.remoteview_notification_icon, R.mipmap.ic_launcher); 
    rv.setTextViewText(R.id.remoteview_notification_headline, "Headline"); 
    rv.setTextViewText(R.id.remoteview_notification_short_message, notificationContent.getHeading()); 
    Notification notification = mBuilder.build(); 

    if (android.os.Build.VERSION.SDK_INT >= 16) { 
     notification.contentView = rv; //Alternative to .setContent(rv); 
    } 
    mNotificationManager.notify(NOTIFICATION_ID, notification); 

    RemoteViews rvBig = new RemoteViews(context.getPackageName(), R.layout.remoteview_big_notification); 
    rvBig.setImageViewResource(R.id.remoteview_big_notification_icon, R.mipmap.ic_launcher); 
    rvBig.setTextViewText(R.id.remoteview_big_notification_headline, notificationContent.getHeading()); 
    rvBig.setTextViewText(R.id.remoteview_big_notification_full_message, notificationContent.getBodyText()); 
    if (android.os.Build.VERSION.SDK_INT >= 16) { 
     notification.bigContentView = rvBig; 
    } 
    mNotificationManager.notify(NOTIFICATION_ID, notification); 

Das Problem ist meine erweiterte Benachrichtigung wird nicht angezeigt, wenn ich nach unten ziehe? Jede Hilfe wird geschätzt. Es fühlt sich an, als wäre es nur etwas Kleines, das noch nicht richtig eingestellt ist?

Antwort

0

Ich glaube, dass meine intentId möglicherweise nicht einzigartig in meiner App ist. Ich habe gesehen, wie Leute das aktuelle System benutzen, um Einzigartigkeit zu gewährleisten.

NOTIFICATION_ID = system.currenttimemillis(); 

PendingIntent pendingIntent = PendingIntent.getActivity(this, NOTIFICATION_ID, intent, PendingIntent.FLAG_UPDATE_CURRENT); 
notificationManager.notify(NOTIFICATION_ID, builder.build()); 
Verwandte Themen