Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import android.content.Context;
import android.os.Handler;
import android.widget.Toast;

public class Main {
    private static Handler handler;
    private static Context context;

    public static void showToast(final String text) {
        handler.post(new Runnable() {

            @Override
            public void run() {
                Toast.makeText(context, text, Toast.LENGTH_SHORT).show();

            }
        });

    }

    public void showToast(final String text, final int duration) {
        handler.post(new Runnable() {

            @Override
            public void run() {
                Toast.makeText(context, text, duration).show();
            }
        });

    }
}