Example usage for android.util Log w

List of usage examples for android.util Log w

Introduction

In this page you can find the example usage for android.util Log w.

Prototype

public static int w(String tag, String msg, Throwable tr) 

Source Link

Document

Send a #WARN log message and log the exception.

Usage

From source file:Main.java

/**
 * Convenience method for writing a warning to the logcat
 * @param warning//from   w w w . java  2  s.c  om
 * @param args
 */
public static void warn(String warning, Object... args) {
    try {
        Method m = Log.class.getMethod("w", new Class<?>[] { String.class, String.class });
        log(m, warning, args);
    } catch (Exception e) {
        Log.w("AbLE", "Log Failed", e);
    }
}

From source file:Main.java

/**
 * Convenience method for writing an error message to the logcat
 * @param error/*from   w  w  w. j  a  va 2s . co m*/
 * @param args
 */
public static void err(String error, Object... args) {
    try {
        Method m = Log.class.getMethod("e", new Class<?>[] { String.class, String.class });
        log(m, error, args);
    } catch (Exception e) {
        Log.w("AbLE", "Log Failed", e);
    }
}

From source file:Main.java

/**
 * Convenience method for writing a debug message to the logcat
 * @param debug/*from   w ww. j a  va2  s  .co m*/
 * @param args
 */
public static void debug(String debug, Object... args) {
    try {
        Method m = Log.class.getMethod("d", new Class<?>[] { String.class, String.class });
        log(m, debug, args);
    } catch (Exception e) {
        Log.w("AbLE", "Log Failed", e);
    }
}

From source file:Main.java

static <T> T instantiateTransformer(Context context, String className) {
    try {/*from ww  w  . j  a  va 2s  . c o  m*/
        Class<?> clazz = context.getClassLoader().loadClass(className);
        return newInstance(context, clazz, TRANSFORMER_CONSTRUCTOR_SIGNATURE);
    } catch (Exception e) {
        Log.w(LOG_TAG, "Cannot instantiate class: " + className, e);
    }
    return null;
}

From source file:Main.java

/**
 * Convenience method for writing information to the logcat
 * @param information//from w w  w  . ja  v a2 s  .com
 * @param args
 */
public static void info(String information, Object... args) {
    try {
        Method m = Log.class.getMethod("i", new Class<?>[] { String.class, String.class });
        log(m, information, args);
    } catch (Exception e) {
        Log.w("AbLE", "Log Failed", e);
    }
}

From source file:Main.java

static <T> T instantiateViewDelegate(Context context, String className) {
    try {//from w  w  w. jav a  2  s  .  c om
        Class<?> clazz = context.getClassLoader().loadClass(className);
        return newInstance(context, clazz, VIEW_DELEGATE_CONSTRUCTOR_SIGNATURE);
    } catch (Exception e) {
        Log.w(LOG_TAG, "Cannot instantiate class: " + className, e);
    }
    return null;
}

From source file:Main.java

public static void closeSilently(ParcelFileDescriptor c) {
    if (c == null)
        return;/*  www  .  j  a va 2s.  co  m*/
    try {
        c.close();
    } catch (Throwable t) {
        Log.w(TAG, "fail to close", t);
    }
}

From source file:Main.java

/**
 * Launch this app store site.//w w  w.ja v  a  2  s .  c  o m
 *
 * @param context Context
 */
public static void launchStore(Context context) {
    try {
        context.startActivity(
                new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + context.getPackageName())));
    } catch (ActivityNotFoundException e) {
        Log.w(TAG, "Occurred ActivityNotFoundException.", e);
    }
}

From source file:Main.java

public static void closeSilently(ParcelFileDescriptor fd) {
    try {// w w  w .  ja va2  s .  c  o  m
        if (fd != null)
            fd.close();
    } catch (Throwable t) {
        Log.w(TAG, "fail to close", t);
    }
}

From source file:Main.java

public static void closeSilently(Cursor cursor) {
    try {//  ww w.j  ava2 s . com
        if (cursor != null)
            cursor.close();
    } catch (Throwable t) {
        Log.w(TAG, "fail to close", t);
    }
}