Prepared and tested with Android Studio and Java (2018-03-27)
Table of contents
Project description
In this project I want to show how to use Toasts and Notifications to communicate with a user.
Requirements:
- There are four buttons: Make basic notification, Make custom notification, Make toast oraz Make custom toast.
- Depending on the type of button we have pressed a correct notification of Notification or Toast type should be displayed.
- custom methods should display our own custom notifications.
- Every time Make notification is pressed, text displayed by this notification should be modified.
All the information needed to complete this project can be found in Materials section.
How it should work
My application is an extended version of what should be done to show three other Notification style (beside standard known as Basic and custom under the Custom name):
- InboxStyle - allows to display message in max. 6 rows.
- BigTextStyle - allows to display on big block of text.
- BigPictureStyle - allows to display image and text.
- On the main screen a set of buttons intended to display a selected toast/notification should be visible.
Press Make basic notification button. - Slide your finger from the top edge of the screen to display a list of Notification
Clear notification list and press Make inbox style notification. - Display a list of Notification - you should see InboxStyle style notification
Clear notification list and press Make big text style notification. - Display a list of Notification - you should see BigTextStyle style notification
Clear notification list and press Make big picture style notification. - Display a list of Notification - you should see BigPictureStyle style notification
Clear notification list and press Make custom notification. - Display a list of Notification - you should see a notification created on our own custom layout
Clear notification list and press Make basic notification. - Display a list of Notification - you should see a basic notification as we have seen the first time but with a modified contents (counter value should be changed)
Clear notification list and press Make toast. - Simple Toast notification should be displayed
- A Toast notification created on our own custom layout should be displayed
Source code
For this project the following files were created
- AndroidManifest.xml
- activity_main.xml
- custom_notification.xml
- toast_layout.xml
- MainActivity.java
- strings.xml
Also some resources (images located in res/drawables and mipmap) should be prepared
- res/drawable:
- mipmap: ic_my_notification_icon.png and ic_ja7.png. ic_ files can be easily prepared with right mouse button click on res directory and selecting existing icon (as for ic_my_notification_icon.png) or create a new one based on some image (as for ic_ja7.png prepared based on ).
Materials
- Messaging with Notification
- Messaging with Toast