Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.app.Activity;
import android.content.Context;

import android.widget.Toast;

import java.lang.ref.WeakReference;

public class Main {
    private static Context context;
    private static WeakReference<Activity> activity;

    public static void toast(final String text) {
        Activity a = activity.get();
        if (a == null) {
            return;
        }
        a.runOnUiThread(new Runnable() {
            public void run() {
                Toast.makeText(context, text, Toast.LENGTH_LONG).show();
            }
        });
    }
}