Course Content

If you are facing any issue in playing video please use Firefox browser.

Course Content

Description

What are Android Notifications

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.

Toast Notification

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 :

                                toastBaic .show();

 

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

Android Custom Toast

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.setDuration (Toast.LENGTH_SHORT);

                toast.setGravity (Gravity.CENTER_VERTICAL, 0, 0);

                toast.setView(layout);//setting the view of custom toast layout

                toast.show();

Android Alert Dialog

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?

Android Fragment

With this we can show ‘Yes or No’ along with the message.

Snackbar

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.

Statusbar Notification

Any notification that looks like an icon on our screen even when our mobile is locked is called statusbar notification.

FAQs

Recommended Courses

Share With Friend

Have a friend to whom you would want to share this course?

Download The Apps

Code Scan or Download the app
Google Play Store
297K+ Downloads
4.5 Rating
10K+ Reviews
  • Learn anywhere on the go
  • Get regular updates about your enrolled or new courses
  • Share content with your friends
  • Evaluate your progress through practice tests
  • No internet connection needed
  • Enroll for the webinar and join at the time of the webinar from anywhere