Toast Message Notification

public static void displayToast(Context c, String text, int duration, int gravity) {
 Toast t = Toast.makeText(c, text, duration);
 t.setGravity(gravity, 0, 0);;
public boolean onTouchEvent(MotionEvent event) {
 if(event.getAction() == MotionEvent.ACTION_DOWN) {
 QuickToast.displayToast(this, "Center toast", Toast.LENGTH_LONG, Gravity.CENTER); // set gravity to the center
 return super.onTouchEvent(event);

Or simple like this :

Toast.makeText(MainActivity.this, "your message here",Toast.LENGTH_LONG).show();

One thought on “Toast Message Notification

  1. Pingback: Android | David Ng

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s