Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ViewFlipper inside Remoteview showNext() and showPrevious() not working

I am working in a project where I need to use ViewFlipper view inside Remoteview in Notification bar. Currently am facing issue with a showNext() and showPreview(). But unfortunately showNext() and showPreview() are not called when I call the button. I am also posting my code for your reference. Kindly help me where I am making mistake and correct me if my question is not clear.

 private Notification setCustomViewNotification() {

        // Creates an explicit intent for an ResultActivity to receive.
        Intent resultIntent = new Intent(this, ResultActivity.class);

        // This ensures that the back button follows the recommended convention for the back key.
        TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);

        // Adds the back stack for the Intent (but not the Intent itself)
        stackBuilder.addParentStack(ResultActivity.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);

        // Create remote view and set bigContentView.
         expandedView = new RemoteViews(this.getPackageName(), R.layout.notification_viewflipper);
//        expandedView.set(R.id.text_view, "Neat logo!");

        expandedView.setOnClickPendingIntent(R.id.img_left,getPendingSelfIntent(MainActivity.this, IMAGE_LEFT));
        expandedView.setOnClickPendingIntent(R.id.img_right,getPendingSelfIntent(MainActivity.this, IMAGE_RIGHT));


        Notification notification = new NotificationCompat.Builder(this)
                .setSmallIcon(R.drawable.ic_launcher)
                .setAutoCancel(true)
                .setContentIntent(resultPendingIntent)
                .setContentTitle("Custom View").build();

        notification.bigContentView = expandedView;

        return notification;
    }

so when a click event is triggered I have to change the ViewFlipper items. Following is the code where I stuck up completely.

public void onEvent(ViewFlipperClickEvent event){
        if(event.getTag().equals(MainActivity.IMAGE_LEFT)){


            expandedView.showPrevious(R.id.ViewFlipper01);

        }else if(event.getTag().equals(MainActivity.IMAGE_RIGHT)){
            expandedView.showNext(R.id.ViewFlipper01);

        }
    }

Thanks in advance

like image 658
Chandru Avatar asked Nov 09 '22 22:11

Chandru


1 Answers

You need to notify the change to your push notification Try something like-

notificationBig.showNext(R.id.vf_carousel)
notificationManager.notify(0, customNotif.build())

Here 0 will be the unique ID of your notification that you need to update

like image 161
Anirudh Avatar answered Nov 14 '22 22:11

Anirudh