Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.app.Activity;

import android.content.SharedPreferences;

import android.widget.Toast;

public class Main {
    private static Toast percentToast;

    public static void showPercentToast(boolean show, Activity a, SharedPreferences prefs, double brightness) {

        if (percentToast == null) {
            percentToast = Toast.makeText(a, "", Toast.LENGTH_SHORT);
        }

        percentToast.setText(new Integer((int) (brightness / 2.55)).toString() + "%");

        if (show) {
            if (prefs.getBoolean("showToast", true))
                percentToast.show();
        } else {
            percentToast.cancel();
        }
    }
}