Android 开发 常用工具类收藏
2018-05-17 本文已影响60人
吾乃韩小呆
说在前面,以下工具类可以大大的提高安卓开发者的开发效率
1、偏好设置(ShareUtils)
import android.content.Context;
import android.content.SharedPreferences;
/**
* Content:偏好设置工具类
* Actor:韩小呆 ヾ(✿゚▽゚)ノ
* Time: 15:44
*/
public class ShareUtils {
public static final String NAME = "config.hxd";
/**
* 存入数据(String)
*/
public static void putString(Context context, String key, String value) {
//获得偏好设置
SharedPreferences spf = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
//向偏好设置内部添加数据并且提交
spf.edit().putString(key, value).apply();
}
/**
* 取数据(上下文,钥匙,未取得数据返回的默认值)(String)
*/
public static String getString(Context context, String key, String value) {
//获得偏好设置
SharedPreferences spf = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
//返回需要取得的数据
return spf.getString(key, value);
}
/**
* 存入数据(Int)
*/
public static void putInt(Context context, String key, int value) {
//获得偏好设置
SharedPreferences spf = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
//向偏好设置内部添加数据并且提交
spf.edit().putInt(key, value).apply();
}
/**
* 取数据(上下文,钥匙,未取得数据返回的默认值)(Int)
*/
public static int getInt(Context context, String key, int value) {
//获得偏好设置
SharedPreferences spf = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
//返回需要取得的数据
return spf.getInt(key, value);
}
/**
* 存入数据(Int)
*/
public static void putBoolean(Context context, String key, boolean value) {
//获得偏好设置
SharedPreferences spf = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
//向偏好设置内部添加数据并且提交
spf.edit().putBoolean(key, value).apply();
}
/**
* 取数据(上下文,钥匙,未取得数据返回的默认值)(Int)
*/
public static boolean getBoolean(Context context, String key, boolean value) {
//获得偏好设置
SharedPreferences spf = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
//返回需要取得的数据
return spf.getBoolean(key, value);
}
/**
* 删除单个偏好设置
*/
public static void deleteShare(Context context, String key) {
//获得偏好设置
SharedPreferences spf = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
spf.edit().remove(key).apply();
}
/**
* 删除所有偏好设置
*/
public static void deleteShareAll(Context context, String key) {
//获得偏好设置
SharedPreferences spf = context.getSharedPreferences(NAME, Context.MODE_PRIVATE);
spf.edit().clear().apply();
}
}
鸿神的偏好设置工具类
具体地址为: https://blog.csdn.net/lmj623565791/article/details/38965311
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import android.content.Context;
import android.content.SharedPreferences;
public class SPUtils
{
/**
* 保存在手机里面的文件名
*/
public static final String FILE_NAME = "share_data";
/**
* 保存数据的方法,我们需要拿到保存数据的具体类型,然后根据类型调用不同的保存方法
*
* @param context
* @param key
* @param object
*/
public static void put(Context context, String key, Object object)
{
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
if (object instanceof String)
{
editor.putString(key, (String) object);
} else if (object instanceof Integer)
{
editor.putInt(key, (Integer) object);
} else if (object instanceof Boolean)
{
editor.putBoolean(key, (Boolean) object);
} else if (object instanceof Float)
{
editor.putFloat(key, (Float) object);
} else if (object instanceof Long)
{
editor.putLong(key, (Long) object);
} else
{
editor.putString(key, object.toString());
}
SharedPreferencesCompat.apply(editor);
}
/**
* 得到保存数据的方法,我们根据默认值得到保存的数据的具体类型,然后调用相对于的方法获取值
*
* @param context
* @param key
* @param defaultObject
* @return
*/
public static Object get(Context context, String key, Object defaultObject)
{
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
if (defaultObject instanceof String)
{
return sp.getString(key, (String) defaultObject);
} else if (defaultObject instanceof Integer)
{
return sp.getInt(key, (Integer) defaultObject);
} else if (defaultObject instanceof Boolean)
{
return sp.getBoolean(key, (Boolean) defaultObject);
} else if (defaultObject instanceof Float)
{
return sp.getFloat(key, (Float) defaultObject);
} else if (defaultObject instanceof Long)
{
return sp.getLong(key, (Long) defaultObject);
}
return null;
}
/**
* 移除某个key值已经对应的值
* @param context
* @param key
*/
public static void remove(Context context, String key)
{
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.remove(key);
SharedPreferencesCompat.apply(editor);
}
/**
* 清除所有数据
* @param context
*/
public static void clear(Context context)
{
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sp.edit();
editor.clear();
SharedPreferencesCompat.apply(editor);
}
/**
* 查询某个key是否已经存在
* @param context
* @param key
* @return
*/
public static boolean contains(Context context, String key)
{
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
return sp.contains(key);
}
/**
* 返回所有的键值对
*
* @param context
* @return
*/
public static Map<String, ?> getAll(Context context)
{
SharedPreferences sp = context.getSharedPreferences(FILE_NAME,
Context.MODE_PRIVATE);
return sp.getAll();
}
/**
* 创建一个解决SharedPreferencesCompat.apply方法的一个兼容类
*
* @author zhy
*
*/
private static class SharedPreferencesCompat
{
private static final Method sApplyMethod = findApplyMethod();
/**
* 反射查找apply的方法
*
* @return
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private static Method findApplyMethod()
{
try
{
Class clz = SharedPreferences.Editor.class;
return clz.getMethod("apply");
} catch (NoSuchMethodException e)
{
}
return null;
}
/**
* 如果找到则使用apply执行,否则使用commit
*
* @param editor
*/
public static void apply(SharedPreferences.Editor editor)
{
try
{
if (sApplyMethod != null)
{
sApplyMethod.invoke(editor);
return;
}
} catch (IllegalArgumentException e)
{
} catch (IllegalAccessException e)
{
} catch (InvocationTargetException e)
{
}
editor.commit();
}
}
}
2、单位转换和屏幕尺寸获取工具类
import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;
/**
* Content:单位转换和屏幕尺寸获取工具类
* Actor:韩小呆 ヾ(✿゚▽゚)ノ
* Time: 15:44
*/
public class DensityUtil {
/**
* 将px值转换为 dip或dp值,保证尺寸大小不变
*
* @param pxValue 像素值
* @param context Context 对象
* @return dp值
*/
public static int px2dip(float pxValue, Context context) {
float scale = getDensity(context);
return (int) (pxValue / scale + 0.5f);
}
/**
* 将dip或dp值转换为px值,保证尺寸大小不变
*
* @param dipValue dip数值
* @param context Context 对象
* @return 像素值
*/
public static int dip2px(float dipValue, Context context) {
float scale = getDensity(context);
return (int) (dipValue * scale + 0.5f);
}
/**
* 将px值转换为sp值,保证文字大小不变
*
* @param pxValue 像素值
* @param context Context 对象
* @return 返回sp数值
*/
public static int px2sp(float pxValue, Context context) {
float scale = getDensity(context);
return (int) (pxValue / scale + 0.5f);
}
/**
* 将sp值转换为px值,保证文字大小不变
*
* @param spValue sp数值
* @param context Context 对象
* @return 返回像素值
*/
public static int sp2px(float spValue, Context context) {
float scale = getDensity(context);
return (int) (spValue * scale + 0.5f);
}
/**
* 取得手机屏幕的密度
*
* @param context 上下文
* @return 手机屏幕的密度
*/
public static float getDensity(Context context) {
float scale = context.getResources().getDisplayMetrics().density;
return scale;
}
/**
* 获取屏幕高
* @param activity
* @return 手机屏幕的高度
*/
public static int getScreenHeight(Activity activity) {
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
return dm.heightPixels;
}
/**
* 获取屏幕宽
* @param activity
* @return 手机屏幕的宽度
*/
public static int getScreenWidth(Activity activity) {
DisplayMetrics dm = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
return dm.widthPixels;
}
}
3、时间转换工具类
import android.annotation.SuppressLint;
import android.text.format.Time;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* Content:时间转换工具类
* Actor:韩小呆 ヾ(✿゚▽゚)ノ
* Time: 15:44
*/
public class DateUtils {
/**
* 获取当前时间
*
* @return 年月日时分秒字符串
*/
public static String getCurrentTime() {
Time time = new Time("GMT+8");
time.setToNow();
String year = "" + time.year;
int imonth = time.month + 1;
String month = imonth > 9 ? "" + imonth : "0" + imonth;
String day = time.monthDay > 9 ? "" + time.monthDay : "0"
+ time.monthDay;
String hour = (time.hour + 8) > 9 ? "" + (time.hour + 8) : "0"
+ (time.hour + 8);
String minute = time.minute > 9 ? "" + time.minute : "0" + time.minute;
String sec = time.second > 9 ? "" + time.second : "0" + time.second;
String currentTime = year + month + day + hour + minute + sec;
return currentTime;
}
//获取 日期/时/分/秒
@SuppressLint("SimpleDateFormat")
public static String getDateTime(long time) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String date = sdf.format(new Date(time));
return date;
}
//获取 日期/时/分
@SuppressLint("SimpleDateFormat")
public static String getHourMinute(long time) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日HH时mm分");
String date = sdf.format(new Date(time));
return date;
}
//获取 日期年月日
@SuppressLint("SimpleDateFormat")
public static String getYearMonthDay(long time) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
String date = sdf.format(new Date(time));
return date;
}
//获取日期年月
public static String getYearMonth(long time){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月");
String date = sdf.format(new Date(time));
return date;
}
//获取日期年月
public static String getYearMonth2(long time){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
String date = sdf.format(new Date(time));
return date;
}
//获取日期年
public static String getYear(long time){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年");
String date = sdf.format(new Date(time));
return date;
}
//获取 时/分
public static String getTime(long time) {
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm");
String date = sdf.format(new Date(time));
return date;
}
}
4、验证码倒计时及重新发送验证码的工具类
import android.os.CountDownTimer;
import android.widget.Button;
/**
* Content:验证码倒计时及重新发送验证码的工具类
* Actor:韩小呆 ヾ(✿゚▽゚)ノ
* Time: 15:44
*/
public class MyCountDownTimer extends CountDownTimer {
private Button mBtn;
private int mEnable;
private int mDisable;
/**
* @param millisInFuture The number of millis in the future from the call
* to {@link #start()} until the countdown is done and {@link #onFinish()}
* is called.
* @param countDownInterval The interval along the way to receive
* {@link #onTick(long)} callbacks.
*/
public MyCountDownTimer(long millisInFuture, long countDownInterval, Button btn, int enable, int disable) {
super(millisInFuture, countDownInterval);
mBtn = btn;
mEnable = enable;
mDisable = disable;
}
//计时过程
@Override
public void onTick(long l) {
//防止计时过程中重复点击
mBtn.setClickable(false);
mBtn.setText(l / 1000 + "s");
//设置按钮背景色
mBtn.setBackgroundResource(mDisable);
}
//计时完毕的方法
@Override
public void onFinish() {
//重新给Button设置文字
mBtn.setText("重新获取验证码");
//设置可点击
mBtn.setClickable(true);
//设置按钮背景色
mBtn.setBackgroundResource(mEnable);
}
}
6、进度Dialog工具类
import android.app.ProgressDialog;
import android.content.Context;
/**
* Content:进度Dialog工具类
* Actor:韩小呆 ヾ(✿゚▽゚)ノ
* Time: 15:44
*/
public class ProgressDlgUtil {
private static ProgressDialog progressDlg = null;
/**
* 启动进度条
* @param ctx 当前的activity
* @param content 进度条显示的信息
*/
public static void show(Context ctx, String content) {
if (null == progressDlg) {
progressDlg = new ProgressDialog(ctx);
progressDlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);// 设置进度条的形式为圆形转动的进度条
//progressDlg.setTitle("提示");//设置进度条标题
progressDlg.setMessage(content);//提示的消息
progressDlg.setIndeterminate(false);
progressDlg.setCancelable(false);
//progressDlg.setIcon(R.drawable.ic_launcher_scale);
progressDlg.show();
}
}
/**
* 结束进度条
*/
public static void dismiss() {
if (null != progressDlg) {
progressDlg.dismiss();
progressDlg = null;
}
}
}
7、吐司工具类
import android.annotation.SuppressLint;
import android.content.Context;
import android.widget.Toast;
/**
* Content:ToastUtils
* Actor:韩小呆 ヾ(✿゚▽゚)ノ
* Time: 2018/5/17 17:37
*/
public class ToastUtils {
private ToastUtils() {
throw new UnsupportedOperationException("禁止实例化");
}
private static boolean isShow = true;
private static Toast toast;
/**
* 短时间显示Toast
*
* @param context 上下文
* @param msg 显示内容
*/
@SuppressLint("ShowToast")
public static void showToast(Context context, String msg) {
if (isShow && toast == null) {
//第一次创建
toast = Toast.makeText(context, msg, Toast.LENGTH_SHORT);
} else {
//如果toast存在,只修改文字,防止点的次数多一直弹出
toast.setText(msg);
}
toast.show();
}
/**
* 短时间显示Toast
*
* @param context 上下文
* @param msgResID 显示内容
*/
@SuppressLint("ShowToast")
public static void showToast(Context context, int msgResID) {
if (isShow && toast == null) {
toast = Toast.makeText(context, msgResID, Toast.LENGTH_SHORT);
} else {
toast.setText(msgResID);
}
toast.show();
}
/**
* 长时间显示Toast
*
* @param context 上下文
* @param message 显示内容
*/
@SuppressLint("ShowToast")
public static void showLong(Context context, CharSequence message) {
if (isShow && toast == null) {
toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
} else {
toast.setText(message);
}
toast.show();
}
/**
* 长时间显示Toast
*
* @param context 上下文
* @param message 显示内容
*/
@SuppressLint("ShowToast")
public static void showLong(Context context, int message) {
if (isShow && toast == null) {
toast = Toast.makeText(context, message, Toast.LENGTH_LONG);
} else {
toast.setText(message);
}
toast.show();
}
/**
* 自定义显示Toast时间
*
* @param context 上下文
* @param message 显示内容
* @param duration 显示时间
*/
public static void show(Context context, CharSequence message, int duration) {
if (isShow) Toast.makeText(context, message, duration).show();
}
/**
* 自定义显示Toast时间
*
* @param context 上下文
* @param message 显示内容
* @param duration 显示时间
*/
public static void show(Context context, int message, int duration) {
if (isShow) Toast.makeText(context, message, duration).show();
}
8、软键盘操作工具类
mport android.content.Context;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
/**
* Content:打开关闭软键盘
* Actor:韩小呆 ヾ(✿゚▽゚)ノ
* Time: 2018/5/17 17:37
*/
public class KeyBoardUtils {
/**
* 打卡软键盘
*
* @param mEditText 输入框
* @param mContext 上下文
*/
public static void openKeyBord(EditText mEditText, Context mContext) {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
assert imm != null;
imm.showSoftInput(mEditText, InputMethodManager.RESULT_SHOWN);
imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}
/**
* 关闭软键盘
*
* @param mEditText 输入框
* @param mContext 上下文
*/
public static void closeKeyBord(Context mContext , EditText mEditText ) {
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
assert imm != null;
imm.hideSoftInputFromWindow(mEditText.getWindowToken(), 0);
}
/**
* 判断软键盘是否弹出
*
* @param context 上下文
* @param v 控件
* @return 是否关闭
*/
public static boolean isSHowKeyboard(Context context, View v) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
assert imm != null;
if (imm.hideSoftInputFromWindow(v.getWindowToken(), 0)) {
imm.showSoftInput(v, 0);
return true;
//软键盘已弹出
} else {
return false;
//软键盘未弹出
}
}
}
9、网络相关工具类
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
/**
* Content:网络相关判断操作
* Actor:鸿神
* Time:2018/3/30
*/
public class NetUtils {
private NetUtils() {
throw new UnsupportedOperationException("cannot be instantiated");
}
/**
* 判断网络是否连接
*
* @param context
* @return
*/
public static boolean isConnected(Context context) {
ConnectivityManager connectivity = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
if (null != connectivity) {
NetworkInfo info = connectivity.getActiveNetworkInfo();
if (null != info && info.isConnected()) {
if (info.getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
return false;
}
/**
* 判断是否是wifi连接
*/
public static boolean isWifi(Context context) {
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context
.CONNECTIVITY_SERVICE);
if (cm == null) {
return cm.getActiveNetworkInfo().getType() == ConnectivityManager.TYPE_WIFI;
}
return false;
}
/**
* 打开网络设置界面
*/
public static void openSetting(Activity activity) {
Intent intent = new Intent("/");
ComponentName cm = new ComponentName("com.android.settings",
"com.android.settings.WirelessSettings");
intent.setComponent(cm);
intent.setAction("android.intent.action.VIEW");
activity.startActivityForResult(intent, 0);
}
}
10、dp、px、sp之间的转换工具类
import android.content.Context;
import android.util.DisplayMetrics;
/**
* Used 尺寸转换工具类(全)
*/
public class DensityUtil {
public static float RATIO = 0.95F;//缩放比例值
/**
* px 转 dp【按照一定的比例】*/
public static int px2dipRatio(Context context, float pxValue) {
float scale = getScreenDendity(context) * RATIO;
return (int)((pxValue / scale) + 0.5f);
}
/**
* dp转px【按照一定的比例】*/
public static int dip2pxRatio(Context context, float dpValue) {
float scale = getScreenDendity(context) * RATIO;
return (int)((dpValue * scale) + 0.5f);
}
/**
* px 转 dp
* 48px - 16dp
* 50px - 17dp*/
public static int px2dip(Context context, float pxValue) {
float scale = getScreenDendity(context);
return (int)((pxValue / scale) + 0.5f);
}
/**
* dp转px
* 16dp - 48px
* 17dp - 51px*/
public static int dip2px(Context context, float dpValue) {
float scale = getScreenDendity(context);
return (int)((dpValue * scale) + 0.5f);
}
/**获取屏幕的宽度(像素)*/
public static int getScreenWidth(Context context) {
return context.getResources().getDisplayMetrics().widthPixels;//1080
}
/**获取屏幕的宽度(dp)*/
public static int getScreenWidthDp(Context context) {
float scale = getScreenDendity(context);
return (int)(context.getResources().getDisplayMetrics().widthPixels / scale);//360
}
/**获取屏幕的高度(像素)*/
public static int getScreenHeight(Context context) {
return context.getResources().getDisplayMetrics().heightPixels;//1776
}
/**获取屏幕的高度(像素)*/
public static int getScreenHeightDp(Context context) {
float scale = getScreenDendity(context);
return (int)(context.getResources().getDisplayMetrics().heightPixels / scale);//592
}
/**屏幕密度比例*/
public static float getScreenDendity(Context context){
return context.getResources().getDisplayMetrics().density;//3
}
/**获取状态栏的高度 72px
* http://www.2cto.com/kf/201501/374049.html*/
public static int getStatusBarHeight(Context context) {
int statusHeight = -1;
try {
Class<?> aClass = Class.forName("com.android.internal.R$dimen");
Object object = aClass.newInstance();
int height = Integer.parseInt(aClass.getField("status_bar_height").get(object).toString());
statusHeight = context.getResources().getDimensionPixelSize(height);
} catch (Exception e) {
e.printStackTrace();
}
return statusHeight;
//依赖于WMS(窗口管理服务的回调)【不建议使用】
/*Rect outRect = new Rect();
((Activity)context).getWindow().getDecorView().getWindowVisibleDisplayFrame(outRect);
return outRect.top;*/
}
/**
* 指定机型(displayMetrics.xdpi)下dp转px
* 18dp - 50px*/
public static int dpToPx(Context context, int dp) {
return Math.round(((float)dp * getPixelScaleFactor(context)));
}
/**
* 指定机型(displayMetrics.xdpi)下px 转 dp
* 50px - 18dp*/
public static int pxToDp(Context context, int px) {
return Math.round(((float)px / getPixelScaleFactor(context)));
}
/**获取水平方向的dpi的密度比例值
* 2.7653186*/
public static float getPixelScaleFactor(Context context) {
DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
return (displayMetrics.xdpi / 160.0f);
}
}
11、自用Log工具类
import android.util.Log;
/**
* Content:
* Actor:韩小呆 ヾ(✿゚▽゚)ノ
* Time: 2018/6/29 9:31
* Update:
* Time: 2018/6/29 9:31
*/
public class LogUtils {
private static final String TAG = "HXD";
private static final int LOG_LEVEL_VERBOSE = 0;
private static final int LOG_LEVEL_DEBUG = 1;
private static final int LOG_LEVEL_INFO = 2;
private static final int LOG_LEVEL_WARN = 3;
private static final int LOG_LEVEL_ERROR = 4;
private static int outputLevel = LOG_LEVEL_VERBOSE;
private LogUtils() {
super();
}
/**
* 控制原生Log是否打印
* level>4 则不打印原生 日志,反之则打印原生日志
*
* @param level 控制标志位
*/
public static void setOutputLevel(int level) {
outputLevel = level;
}
public static void v(String tag, String msg) {
if (outputLevel <= LOG_LEVEL_VERBOSE) {
Log.v(tag, msg);
}
}
public static void v(String msg) {
v(TAG, msg);
}
public static void d(String tag, String msg) {
if (outputLevel <= LOG_LEVEL_DEBUG) {
Log.d(tag, msg);
}
}
public static void d(String msg) {
d(TAG, msg);
}
public static void i(String tag, String msg) {
if (outputLevel <= LOG_LEVEL_INFO) {
Log.i(tag, msg);
}
}
public static void i(String msg) {
i(TAG, msg);
}
public static void w(String tag, String msg) {
if (outputLevel <= LOG_LEVEL_WARN) {
Log.w(tag, msg);
}
}
public static void w(String msg) {
w(TAG, msg);
}
public static void e(String tag, String msg) {
if (outputLevel <= LOG_LEVEL_ERROR) {
Log.e(tag, msg);
}
}
public static void e(String msg) {
e(TAG, msg);
}
}