SlideShare a Scribd company logo
Ahmad Arif Faizin
Google Associate Android Developer, Curriculum Developer Dicoding
Pesan yang tampil di luar aplikasi
Biasanya untuk reminder / info baru
Ketika di-tap bisa melakukan aksi tertentu
1
2 3
5
4
Status Bar Lock Screen
Notification Drawer Heads-up Notification App icon badge
1. Small Icon
2. App Name
3. Time stamp
4. Large Icon
5. Content Title
6. Content Text
val notifManager = context.getSystemService(Context.NOTIFICATION_SERVICE)
as NotificationManager
val builder = NotificationCompat.Builder(context, CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_launcher) //1
.setContentTitle("You've been notified!") //2
.setContentText("This is your notification text.") //3
val notification = builder.build()
notifManager.notify(NOTIFICATION_ID, notification)
Tidak muncul, karena harus ada
● Digunakan supaya pengguna bisa
menyesuaikan setiap jenis
notification yang akan ditampilkan.
● Satu channel bisa berisi lebih dari
satu notification.
● Anda bisa menyetel banyak
notification dalam 1 channel
sekaligus seperti prioritas, suara,
getar, cahaya dsb.
User-visible importance level
Importance (Android 8.0
and higher)
Priority (Android 7.1 and
lower)
Urgent
Makes a sound and appears as a heads-up notification
IMPORTANCE_HIGH
PRIORITY_HIGH or
PRIORITY_MAX
High
Makes a sound
IMPORTANCE_DEFAULT PRIORITY_DEFAULT
Medium
No sound
IMPORTANCE_LOW PRIORITY_LOW
Low
No sound and doesn't appear in the status bar
IMPORTANCE_MIN PRIORITY_MIN
// After create NotificationManager and Notification.Builder
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val channel = NotificationChannel(CHANNEL_ID,
"Firing alarms & timers",
NotificationManager.IMPORTANCE_DEFAULT)
channel.enableVibration(true)
channel.vibrationPattern = longArrayOf(1000, 1000, 1000, 1000, 1000)
builder.setChannelId(CHANNEL_ID)
notifManager.createNotificationChannel(channel)
}
val notification = builder.build()
notifManager.notify(NOTIFICATION_ID, notification)
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("http://dicoding.com"))
// OR : val intent = Intent(this, MainActivity::class.java)
val pendingIntent = PendingIntent.getActivity(this, 0, intent,
PendingIntent.FLAG_UPDATE_CURRENT)
val builder = NotificationCompat.Builder(this, CHANNEL_ID)
.setContentIntent(pendingIntent)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("You've been notified!")
.setContentText("This is your notification text.")
// Create the TaskStackBuilder
val resultIntent = Intent(this, ResultActivity::class.java)
val resultPendingIntent: PendingIntent? =
TaskStackBuilder.create(this).run {
// Add the intent, which inflates the back stack
addNextIntentWithParentStack(resultIntent)
// Get the PendingIntent containing the entire back stack
getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT)
}
// AndroidManifest.xml
<activity
android:name=".ResultActivity"
android:parentActivityName=".MainActivity" />
val builder = NotificationCompat.Builder(this, CHANNEL_ID)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("You've been notified!")
.setContentText("This is your notification text.")
● Big Text Style
● Big Image Style
● Message Style
● Media Style
val androidImage = BitmapFactory.decodeResource(
resources,
R.drawable.mascot_1)
val notif = NotificationCompat.Builder(this)
.setContentTitle("New photo from " + sender.toString())
.setContentText(subject)
.setSmallIcon(R.drawable.new_post)
.setLargeIcon(androidImage)
.setStyle(NotificationCompat.BigPictureStyle()
.bigPicture(androidImage)
.setBigContentTitle("Large Notification Title"))
.build()
● Update/cancel dengan panggil notify dengan id yang sama.
● Gunakan setAutoCancel() supaya ketika notif di-tap langsung hilang.
val mBuilder = NotificationCompat.Builder(this, CHANNEL_ID)
.setAutoCancel(true)
...
notifManager.notify(NOTIFICATION_ID) //update
notifManager.cancel(NOTIFICATION_ID) //cancel
● Relevant : Berikan informasi yang esensial saja
● Timely : Jangan sering-sering, nanti di-disable!
● Short : Gunakan kalimat sesingkat mungkin
● Power to choose : Kelompokkan channel supaya user bisa memilih
Contact:
@arif_faizin
Follow us: @dicoding

More Related Content

Similar to Dicoding Developer Coaching #22: Android | Cara Membuat Notifikasi di Aplikasi Androidmu

How to Win on the Apple Watch
How to Win on the Apple WatchHow to Win on the Apple Watch
How to Win on the Apple Watch
Natasha Murashev
 
Android notification
Android notificationAndroid notification
Android notificationKrazy Koder
 
Exercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callExercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone call
maamir farooq
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...Robert Nyman
 
Android For All The Things
Android For All The ThingsAndroid For All The Things
Android For All The Things
Paul Trebilcox-Ruiz
 
How to create android push notifications with custom view
How to create android push notifications with custom viewHow to create android push notifications with custom view
How to create android push notifications with custom view
PushApps - Content Recommendation in Push Notifications
 
Android Wear Development
Android Wear DevelopmentAndroid Wear Development
Android Wear Development
Takahiro (Poly) Horikawa
 
Session #8 adding magic to your app
Session #8  adding magic to your appSession #8  adding magic to your app
Session #8 adding magic to your app
Vitali Pekelis
 
Developing for android wear
Developing for android wearDeveloping for android wear
Developing for android wear
Thomas Oldervoll
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonRobert Nyman
 
Developing for Android Wear
Developing for Android WearDeveloping for Android Wear
Developing for Android Wear
Can Elmas
 
Event handling63
Event handling63Event handling63
Event handling63myrajendra
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
mharkus
 
Vtlib 1.1
Vtlib 1.1Vtlib 1.1
Vtlib 1.1
Arun n
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Mahmoud Hamed Mahmoud
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
shanmuga rajan
 
Android wearpp
Android wearppAndroid wearpp
Android wearpp
Paul Trebilcox-Ruiz
 
Android action bar and notifications-chapter16
Android action bar and notifications-chapter16Android action bar and notifications-chapter16
Android action bar and notifications-chapter16
Dr. Ramkumar Lakshminarayanan
 
Android tutorial (2)
Android tutorial (2)Android tutorial (2)
Android tutorial (2)
Kumar
 

Similar to Dicoding Developer Coaching #22: Android | Cara Membuat Notifikasi di Aplikasi Androidmu (20)

How to Win on the Apple Watch
How to Win on the Apple WatchHow to Win on the Apple Watch
How to Win on the Apple Watch
 
Android notification
Android notificationAndroid notification
Android notification
 
Exercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone callExercises broadcast receiver,incoming phone call
Exercises broadcast receiver,incoming phone call
 
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W... 	Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
Bringing the open web and APIs to mobile devices with Firefox OS - Whisky W...
 
Android For All The Things
Android For All The ThingsAndroid For All The Things
Android For All The Things
 
How to create android push notifications with custom view
How to create android push notifications with custom viewHow to create android push notifications with custom view
How to create android push notifications with custom view
 
Android Wear Development
Android Wear DevelopmentAndroid Wear Development
Android Wear Development
 
Session #8 adding magic to your app
Session #8  adding magic to your appSession #8  adding magic to your app
Session #8 adding magic to your app
 
Developing for android wear
Developing for android wearDeveloping for android wear
Developing for android wear
 
WebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla LondonWebAPIs & Apps - Mozilla London
WebAPIs & Apps - Mozilla London
 
Developing for Android Wear
Developing for Android WearDeveloping for Android Wear
Developing for Android Wear
 
Event handling63
Event handling63Event handling63
Event handling63
 
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
GDG GeorgeTown Devfest 2014 Presentation: Android Wear: A Developer's Perspec...
 
Vtlib 1.1
Vtlib 1.1Vtlib 1.1
Vtlib 1.1
 
Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development Windows Store app using XAML and C#: Enterprise Product Development
Windows Store app using XAML and C#: Enterprise Product Development
 
Lightning Talk - Xamarin
Lightning Talk - Xamarin Lightning Talk - Xamarin
Lightning Talk - Xamarin
 
JAVA AWT
JAVA AWTJAVA AWT
JAVA AWT
 
Android wearpp
Android wearppAndroid wearpp
Android wearpp
 
Android action bar and notifications-chapter16
Android action bar and notifications-chapter16Android action bar and notifications-chapter16
Android action bar and notifications-chapter16
 
Android tutorial (2)
Android tutorial (2)Android tutorial (2)
Android tutorial (2)
 

More from DicodingEvent

Developer Coaching #114.pdf
Developer Coaching #114.pdfDeveloper Coaching #114.pdf
Developer Coaching #114.pdf
DicodingEvent
 
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
DicodingEvent
 
tantangan menjadi developer di abad 21
tantangan menjadi developer di abad 21tantangan menjadi developer di abad 21
tantangan menjadi developer di abad 21
DicodingEvent
 
Mengenalkan augmented reality (ar) pada snapchat
Mengenalkan augmented reality (ar) pada snapchatMengenalkan augmented reality (ar) pada snapchat
Mengenalkan augmented reality (ar) pada snapchat
DicodingEvent
 
Membangun Aplikasi Serverless di Platfrom AWS
Membangun Aplikasi Serverless di Platfrom AWSMembangun Aplikasi Serverless di Platfrom AWS
Membangun Aplikasi Serverless di Platfrom AWS
DicodingEvent
 
IDCamp X Madrasah: Pengenalan Computational Thinking
IDCamp X Madrasah: Pengenalan Computational ThinkingIDCamp X Madrasah: Pengenalan Computational Thinking
IDCamp X Madrasah: Pengenalan Computational Thinking
DicodingEvent
 
Membuat Produk Digital Terbaik ala Startup Unicorn
Membuat Produk Digital Terbaik ala Startup UnicornMembuat Produk Digital Terbaik ala Startup Unicorn
Membuat Produk Digital Terbaik ala Startup Unicorn
DicodingEvent
 
TechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOpsTechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOps
DicodingEvent
 
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CDTechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
DicodingEvent
 
Membuat Solusi Bermanfaat dengan Programming - Nur Rohman
Membuat Solusi Bermanfaat dengan Programming - Nur RohmanMembuat Solusi Bermanfaat dengan Programming - Nur Rohman
Membuat Solusi Bermanfaat dengan Programming - Nur Rohman
DicodingEvent
 
Potensi karier menjadi ios developer di masa depan
Potensi karier menjadi ios developer di masa depanPotensi karier menjadi ios developer di masa depan
Potensi karier menjadi ios developer di masa depan
DicodingEvent
 
Id camp x dicoding live : persiapan jadi software engineer hebat 101
Id camp x dicoding live : persiapan jadi software engineer hebat 101Id camp x dicoding live : persiapan jadi software engineer hebat 101
Id camp x dicoding live : persiapan jadi software engineer hebat 101
DicodingEvent
 
Tips sukses berkarir sebagai developer dan programmer 2021
Tips sukses berkarir sebagai developer dan programmer 2021Tips sukses berkarir sebagai developer dan programmer 2021
Tips sukses berkarir sebagai developer dan programmer 2021
DicodingEvent
 
Teknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
Teknologi Baru Android di Google I/O 2021 - Andrew KurniadiTeknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
Teknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
DicodingEvent
 
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
DicodingEvent
 
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
DicodingEvent
 
Pengantar Cloud Computing dengan AWS - Petra Novandi Barus
Pengantar Cloud Computing dengan AWS - Petra Novandi BarusPengantar Cloud Computing dengan AWS - Petra Novandi Barus
Pengantar Cloud Computing dengan AWS - Petra Novandi Barus
DicodingEvent
 
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
DicodingEvent
 
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
DicodingEvent
 
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
DicodingEvent
 

More from DicodingEvent (20)

Developer Coaching #114.pdf
Developer Coaching #114.pdfDeveloper Coaching #114.pdf
Developer Coaching #114.pdf
 
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
 
tantangan menjadi developer di abad 21
tantangan menjadi developer di abad 21tantangan menjadi developer di abad 21
tantangan menjadi developer di abad 21
 
Mengenalkan augmented reality (ar) pada snapchat
Mengenalkan augmented reality (ar) pada snapchatMengenalkan augmented reality (ar) pada snapchat
Mengenalkan augmented reality (ar) pada snapchat
 
Membangun Aplikasi Serverless di Platfrom AWS
Membangun Aplikasi Serverless di Platfrom AWSMembangun Aplikasi Serverless di Platfrom AWS
Membangun Aplikasi Serverless di Platfrom AWS
 
IDCamp X Madrasah: Pengenalan Computational Thinking
IDCamp X Madrasah: Pengenalan Computational ThinkingIDCamp X Madrasah: Pengenalan Computational Thinking
IDCamp X Madrasah: Pengenalan Computational Thinking
 
Membuat Produk Digital Terbaik ala Startup Unicorn
Membuat Produk Digital Terbaik ala Startup UnicornMembuat Produk Digital Terbaik ala Startup Unicorn
Membuat Produk Digital Terbaik ala Startup Unicorn
 
TechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOpsTechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOps
 
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CDTechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
 
Membuat Solusi Bermanfaat dengan Programming - Nur Rohman
Membuat Solusi Bermanfaat dengan Programming - Nur RohmanMembuat Solusi Bermanfaat dengan Programming - Nur Rohman
Membuat Solusi Bermanfaat dengan Programming - Nur Rohman
 
Potensi karier menjadi ios developer di masa depan
Potensi karier menjadi ios developer di masa depanPotensi karier menjadi ios developer di masa depan
Potensi karier menjadi ios developer di masa depan
 
Id camp x dicoding live : persiapan jadi software engineer hebat 101
Id camp x dicoding live : persiapan jadi software engineer hebat 101Id camp x dicoding live : persiapan jadi software engineer hebat 101
Id camp x dicoding live : persiapan jadi software engineer hebat 101
 
Tips sukses berkarir sebagai developer dan programmer 2021
Tips sukses berkarir sebagai developer dan programmer 2021Tips sukses berkarir sebagai developer dan programmer 2021
Tips sukses berkarir sebagai developer dan programmer 2021
 
Teknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
Teknologi Baru Android di Google I/O 2021 - Andrew KurniadiTeknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
Teknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
 
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
 
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
 
Pengantar Cloud Computing dengan AWS - Petra Novandi Barus
Pengantar Cloud Computing dengan AWS - Petra Novandi BarusPengantar Cloud Computing dengan AWS - Petra Novandi Barus
Pengantar Cloud Computing dengan AWS - Petra Novandi Barus
 
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
 
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
 
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
 

Recently uploaded

Tom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issueTom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issue
amekonnen
 
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Dutch Power
 
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AwangAniqkmals
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
Sebastiano Panichella
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
gharris9
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Access Innovations, Inc.
 
2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf
Frederic Leger
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Sebastiano Panichella
 
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij
 
Burning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdfBurning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdf
kkirkland2
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
khadija278284
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
faizulhassanfaiz1670
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Sebastiano Panichella
 
ASONAM2023_presection_slide_track-recommendation.pdf
ASONAM2023_presection_slide_track-recommendation.pdfASONAM2023_presection_slide_track-recommendation.pdf
ASONAM2023_presection_slide_track-recommendation.pdf
ToshihiroIto4
 
Gregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics PresentationGregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics Presentation
gharris9
 
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie WellsCollapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Rosie Wells
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
eCommerce Institute
 
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...
SkillCertProExams
 
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Dutch Power
 

Recently uploaded (19)

Tom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issueTom tresser burning issue.pptx My Burning issue
Tom tresser burning issue.pptx My Burning issue
 
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
Presentatie 8. Joost van der Linde & Daniel Anderton - Eliq 28 mei 2024
 
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
AWANG ANIQKMALBIN AWANG TAJUDIN B22080004 ASSIGNMENT 2 MPU3193 PHILOSOPHY AND...
 
International Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software TestingInternational Workshop on Artificial Intelligence in Software Testing
International Workshop on Artificial Intelligence in Software Testing
 
Gregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptxGregory Harris' Civics Presentation.pptx
Gregory Harris' Civics Presentation.pptx
 
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdfSupercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
Supercharge your AI - SSP Industry Breakout Session 2024-v2_1.pdf
 
2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf2024-05-30_meetup_devops_aix-marseille.pdf
2024-05-30_meetup_devops_aix-marseille.pdf
 
Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...Announcement of 18th IEEE International Conference on Software Testing, Verif...
Announcement of 18th IEEE International Conference on Software Testing, Verif...
 
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
Suzanne Lagerweij - Influence Without Power - Why Empathy is Your Best Friend...
 
Burning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdfBurning Issue Presentation By Kenmaryon.pdf
Burning Issue Presentation By Kenmaryon.pdf
 
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdfBonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
Bonzo subscription_hjjjjjjjj5hhhhhhh_2024.pdf
 
Media as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern EraMedia as a Mind Controlling Strategy In Old and Modern Era
Media as a Mind Controlling Strategy In Old and Modern Era
 
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...Doctoral Symposium at the 17th IEEE International Conference on Software Test...
Doctoral Symposium at the 17th IEEE International Conference on Software Test...
 
ASONAM2023_presection_slide_track-recommendation.pdf
ASONAM2023_presection_slide_track-recommendation.pdfASONAM2023_presection_slide_track-recommendation.pdf
ASONAM2023_presection_slide_track-recommendation.pdf
 
Gregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics PresentationGregory Harris - Cycle 2 - Civics Presentation
Gregory Harris - Cycle 2 - Civics Presentation
 
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie WellsCollapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
Collapsing Narratives: Exploring Non-Linearity • a micro report by Rosie Wells
 
María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024María Carolina Martínez - eCommerce Day Colombia 2024
María Carolina Martínez - eCommerce Day Colombia 2024
 
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...
Mastering the Concepts Tested in the Databricks Certified Data Engineer Assoc...
 
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
Presentatie 4. Jochen Cremer - TU Delft 28 mei 2024
 

Dicoding Developer Coaching #22: Android | Cara Membuat Notifikasi di Aplikasi Androidmu

  • 1. Ahmad Arif Faizin Google Associate Android Developer, Curriculum Developer Dicoding
  • 2. Pesan yang tampil di luar aplikasi Biasanya untuk reminder / info baru Ketika di-tap bisa melakukan aksi tertentu
  • 3. 1 2 3 5 4 Status Bar Lock Screen Notification Drawer Heads-up Notification App icon badge
  • 4. 1. Small Icon 2. App Name 3. Time stamp 4. Large Icon 5. Content Title 6. Content Text
  • 5. val notifManager = context.getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager val builder = NotificationCompat.Builder(context, CHANNEL_ID) .setSmallIcon(R.mipmap.ic_launcher) //1 .setContentTitle("You've been notified!") //2 .setContentText("This is your notification text.") //3 val notification = builder.build() notifManager.notify(NOTIFICATION_ID, notification)
  • 7. ● Digunakan supaya pengguna bisa menyesuaikan setiap jenis notification yang akan ditampilkan. ● Satu channel bisa berisi lebih dari satu notification. ● Anda bisa menyetel banyak notification dalam 1 channel sekaligus seperti prioritas, suara, getar, cahaya dsb.
  • 8. User-visible importance level Importance (Android 8.0 and higher) Priority (Android 7.1 and lower) Urgent Makes a sound and appears as a heads-up notification IMPORTANCE_HIGH PRIORITY_HIGH or PRIORITY_MAX High Makes a sound IMPORTANCE_DEFAULT PRIORITY_DEFAULT Medium No sound IMPORTANCE_LOW PRIORITY_LOW Low No sound and doesn't appear in the status bar IMPORTANCE_MIN PRIORITY_MIN
  • 9. // After create NotificationManager and Notification.Builder if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { val channel = NotificationChannel(CHANNEL_ID, "Firing alarms & timers", NotificationManager.IMPORTANCE_DEFAULT) channel.enableVibration(true) channel.vibrationPattern = longArrayOf(1000, 1000, 1000, 1000, 1000) builder.setChannelId(CHANNEL_ID) notifManager.createNotificationChannel(channel) } val notification = builder.build() notifManager.notify(NOTIFICATION_ID, notification)
  • 10. val intent = Intent(Intent.ACTION_VIEW, Uri.parse("http://dicoding.com")) // OR : val intent = Intent(this, MainActivity::class.java) val pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) val builder = NotificationCompat.Builder(this, CHANNEL_ID) .setContentIntent(pendingIntent) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle("You've been notified!") .setContentText("This is your notification text.")
  • 11. // Create the TaskStackBuilder val resultIntent = Intent(this, ResultActivity::class.java) val resultPendingIntent: PendingIntent? = TaskStackBuilder.create(this).run { // Add the intent, which inflates the back stack addNextIntentWithParentStack(resultIntent) // Get the PendingIntent containing the entire back stack getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT) } // AndroidManifest.xml <activity android:name=".ResultActivity" android:parentActivityName=".MainActivity" />
  • 12. val builder = NotificationCompat.Builder(this, CHANNEL_ID) .setSmallIcon(R.mipmap.ic_launcher) .setContentTitle("You've been notified!") .setContentText("This is your notification text.")
  • 13. ● Big Text Style ● Big Image Style
  • 14. ● Message Style ● Media Style
  • 15. val androidImage = BitmapFactory.decodeResource( resources, R.drawable.mascot_1) val notif = NotificationCompat.Builder(this) .setContentTitle("New photo from " + sender.toString()) .setContentText(subject) .setSmallIcon(R.drawable.new_post) .setLargeIcon(androidImage) .setStyle(NotificationCompat.BigPictureStyle() .bigPicture(androidImage) .setBigContentTitle("Large Notification Title")) .build()
  • 16. ● Update/cancel dengan panggil notify dengan id yang sama. ● Gunakan setAutoCancel() supaya ketika notif di-tap langsung hilang. val mBuilder = NotificationCompat.Builder(this, CHANNEL_ID) .setAutoCancel(true) ... notifManager.notify(NOTIFICATION_ID) //update notifManager.cancel(NOTIFICATION_ID) //cancel
  • 17. ● Relevant : Berikan informasi yang esensial saja ● Timely : Jangan sering-sering, nanti di-disable! ● Short : Gunakan kalimat sesingkat mungkin ● Power to choose : Kelompokkan channel supaya user bisa memilih