If you are facing any issue in playing video please use Firefox browser.
Today we will see what are the notifications inside Android, generally when we talk about notification, it is a message that we display to the user outside our application. Whatever notification will be there it will first come in the form of an icon, and then when we drag that icon, we will get the detailed information about what that notification is.
Message sending is a very common thing, we send messages using the network, so this message we send contains a content like delivery report that 'Your message delivered successfully'. So the message will be delivered with the help of toast.
Activity Life Cycle – onPause() | onStart() | onCreate()
The 3 basic things we have to keep in mind within Toast are Content, Message, and Duration.
Call show() to show the Toast, like this :
We can also string everything together like this :
Toast.makeText (this,”My toast message”,Toast.LENGTH_LONG).show();
LENGTH_SHORT - about 2 seconds
LENGTH_LONG - about 4 seconds
Here we will design our own toast, the advantage is that we can place it on any particular area of our screen, and we can also put our custom images in it. Properties we have to set to insert custom toast-
Toast toast = new Toast (get ApplicationContext());
toast.setGravity (Gravity.CENTER_VERTICAL, 0, 0);
toast.setView(layout);//setting the view of custom toast layout
Alert Dialog is a very important concept in any user friendly application we are creating.
Alert Dialog can also be used to show just one message. For example: Are you sure you want to exit ? YES or NO?
With this we can show ‘Yes or No’ along with the message.
A new component introduced in Android material design is snackbar.
It is almost same as toast but with some additional features.
We can add an action in snack bar.
We can also customise colours of the text.
Any notification that looks like an icon on our screen even when our mobile is locked is called statusbar notification.
Have a friend to whom you would want to share this course?