I will probably create a series of blog posts regarding Android notifications, and make it like a cheat sheet for all of us. Anyway, here are some screenshots of today's code output:
|When you run this code.|
|When you click the button "Show Notification",|
the notification bar will have the ninja icon
and you will hear a sound
(make sure you're not in silent mode).
|When you slide down the notification bar.|
How to hide the notification? There are two ways:
1. First, you can click the "Cancel Notification" button.
2. Or, second, swipe the notification to left or right (swipe the notification in the third image).
These ways were set programatically, so read the code (with comments) below.
Here's are our awesome code: MainActivity.java
I also put the ninja icon in our drawable folder, that's the source of our icon.
Please share what Android notification example you want next!
For FREE programming tutorials, click the red button below and subscribe! :)