Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void tampilNotification(View view) {
- Intent intent = new Intent(Intent.ACTION_VIEW,
- Uri.parse("http://www.okedroid.com/"));
- //menginisialiasasi intent
- PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
- //untuk memanggil activity di Notification
- /*
- Menmbangun atau mensetup Notification dengan NotificationCompat.Builder
- */
- NotificationCompat.Builder builder = (NotificationCompat.Builder) new NotificationCompat.Builder(this)
- .setSmallIcon(R.mipmap.ic_launcher) //ikon notification
- .setContentTitle("1 Postingan Baru")//judul konten
- .setContentIntent(pendingIntent)//memanggil object pending intent
- .setAutoCancel(true)//untuk menswipe atau menghapus notification
- .setContentText("Kunjungi blog okedroid.com"); //isi text
- /*
- Kemudian kita harus menambahkan Notification dengan menggunakan NotificationManager
- */
- NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.notify(NOTIFICATION_ID, builder.build()
- );
- }
Advertisement
Add Comment
Please, Sign In to add comment