I am trying to add image and action buttons to a push notification. But this does not work properly.
The notification looks like this when I first click on the button and go to another activity (no image):

But if I go back again and press the button again, the image will appear with a few buttons:

In addition, the context text of the notification is not displayed. Here is the code:
notification.setContentTitle("Successfully Signed Up");
notification.setContentText("Hi, you just Signed Up as a Vendor");
notification.setWhen(System.currentTimeMillis());
notification.setSmallIcon(R.mipmap.ic_launcher);
Intent i=new Intent(this,OrderTypes.class);
PendingIntent pi=PendingIntent.getActivity(this, 0, i, 0);
notification.addAction(R.mipmap.ic_launcher,"Accept",pi);
notification.addAction(R.mipmap.ic_launcher, "Decline", pi);
NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle();
new Thread(new Runnable() {
@Override
public void run() {
try
{
remote_picture = BitmapFactory.decodeStream((InputStream) new URL(getIntent().getExtras().getString("imageurl")).getContent());
}
catch (IOException e)
{
e.printStackTrace();
}
}
}).start();
notiStyle.bigPicture(remote_picture);
notification.setStyle(notiStyle);
Intent intent = new Intent(this, VendorDetails.class);
intent.putExtra("Phone", num);
PendingIntent pendingIntent = PendingIntent.getActivity(Verify.this, 0, intent, 0);
notification.setContentIntent(pendingIntent);
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(uniqueID, notification.build());
New full updated feature:
public void defineNotification(String num) {
new Thread(new Runnable()
{
public void run() {
try {
notification.setContentTitle("New Order Received")
notification.setContentText("Train No.12724 \n Amount 500");
notification.setWhen(System.currentTimeMillis());
notification.setSmallIcon(R.drawable.omitra_notification_icon);
Intent i = new Intent(this, OrderTypes.class);
PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0);
notification.addAction(R.drawable.pink_accept, "Accept", pi);
notification.addAction(R.drawable.pink_decline, "Decline", pi);
notification.setPriority(Notification.PRIORITY_MAX);
NotificationCompat.BigPictureStyle notiStyle = new NotificationCompat.BigPictureStyle();
try {
remote_picture = BitmapFactory.decodeStream((InputStream) new URL(getIntent().getExtras().getString("imageurl")).getContent());
} catch (IOException e) {
e.printStackTrace();
}
notiStyle.setSummaryText("Amount : 500");
notiStyle.bigPicture(remote_picture);
notification.setStyle(notiStyle);
Intent intent = new Intent(this, VendorDetails.class);
intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
intent.putExtra("Phone", num);
PendingIntent pendingIntent = PendingIntent.getActivity(Verify.this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
notification.setContentIntent(pendingIntent);
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(uniqueID, notification.build());
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
}
Does anyone know if I missed something?