public class LayoutActivity extends AppCompatActivity { Button notifybtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_layout);
notifybtn=(Button) findViewById(R.id.button_noti);
notifybtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
PendingIntent pIntent = PendingIntent.getActivity(LayoutActivity.this,0,intent,0);
Notification noti = new Notification.Builder(LayoutActivity.this)
.setTicker("Ticker Title")
.setContentTitle("Content Title")
.setContentText("Bus has Arrived at the station")
.setSmallIcon(R.drawable.aaa)
.addAction(R.drawable.aaa,"Available",pIntent)
.addAction(R.drawable.aaa,"NotAvailable",pIntent)
.setContentIntent(pIntent).getNotification();
noti.flags = Notification.FLAG_AUTO_CANCEL;
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(0,noti);
}
});
}
}
make the notification dissapear in 15min? and does small icon support any type of image?