Example usage for android.util Log i

List of usage examples for android.util Log i

Introduction

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

Prototype

public static int i(String tag, String msg) 

Source Link

Document

Send an #INFO log message.

Usage

From source file:Main.java

public static String getMimeType(String filePath) {
    if (TextUtils.isEmpty(filePath)) {
        return "";
    }// www  .j a v a 2 s.c  om
    String type = null;
    String extension = getExtensionName(filePath.toLowerCase());
    if (!TextUtils.isEmpty(extension)) {
        MimeTypeMap mime = MimeTypeMap.getSingleton();
        type = mime.getMimeTypeFromExtension(extension);
    }
    Log.i(TAG, "url:" + filePath + " " + "type:" + type);

    // FIXME
    if (TextUtils.isEmpty(type) && filePath.endsWith("aac")) {
        type = "audio/aac";
    }

    return type;
}

From source file:Main.java

/**
 * Forget the account name and authToken. With no account name the app will
 * prompt the user to select a new account. This method is mostly used for
 * testing purposes./* w w w .  j a va  2 s .c  o  m*/
 * 
 * @param activity
 */
public static void resetAccountCredential(Activity activity) {
    Log.i(TAG, "Reset credentials");
    SharedPreferences settings = activity.getPreferences(Activity.MODE_PRIVATE);
    SharedPreferences.Editor editor2 = settings.edit();
    editor2.remove(PREF_AUTH_TOKEN);
    editor2.remove(PREF_ACCOUNT_NAME);
    editor2.commit();
}

From source file:Main.java

/**
 * get a bitmap by giving a file location
 * @param fileName//from w  w  w  .j  a va 2 s  . c o m
 * @return
 */
public static Bitmap getImgFromLocation(String fileName) {
    File imgFile = new File(fileName);

    Bitmap myBitmap = null;

    //shows an image on the screen
    if (imgFile.exists()) {

        myBitmap = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
        Log.i(TAG, "file saved");

    } else
        Log.i(TAG, "file not found");

    return myBitmap;
}

From source file:Main.java

static private void log(String format, Object arg1, Object arg2, Object arg3) {
    Log.i(TAG, String.format(format, arg1, arg2, arg3));
}

From source file:Main.java

private static boolean moveFile(File oldPlace, File newPlace, boolean removeOld) {
    boolean removeNewFile = true;
    Log.i("cr3", "Moving file " + oldPlace.getAbsolutePath() + " to " + newPlace.getAbsolutePath());
    if (!oldPlace.exists()) {
        Log.i("cr3", "File " + oldPlace.getAbsolutePath() + " does not exist!");
        return false;
    }/*from  ww w  .ja  v  a 2  s . c  o m*/
    FileOutputStream os = null;
    FileInputStream is = null;
    try {
        if (!newPlace.createNewFile())
            return false; // cannot create file
        os = new FileOutputStream(newPlace);
        is = new FileInputStream(oldPlace);
        byte[] buf = new byte[0x10000];
        for (;;) {
            int bytesRead = is.read(buf);
            if (bytesRead <= 0)
                break;
            os.write(buf, 0, bytesRead);
        }
        removeNewFile = false;
        oldPlace.delete();
        return true;
    } catch (IOException e) {
        return false;
    } finally {
        try {
            if (os != null)
                os.close();
        } catch (IOException ee) {
            // ignore
        }
        try {
            if (is != null)
                is.close();
        } catch (IOException ee) {
            // ignore
        }
        if (removeNewFile)
            newPlace.delete();
    }
}

From source file:Main.java

public static String getAppName(Context context) {
    String appName = null;//w w  w.ja  v  a2  s .  c  o  m
    try {
        PackageManager packageManager = context.getPackageManager();
        ApplicationInfo applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0);
        appName = packageManager.getApplicationLabel(applicationInfo).toString();
        Log.i("liweiping", "appName = " + appName);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return appName;
}

From source file:Main.java

/**
 * Reset all error flags to 0.//from  w w  w. ja  v  a 2 s  . c om
 */
public static void resetErrorFlags() {
    Log.i(TAG, "Reset all error flags.");

    Properties prop = new Properties();

    prop.put(ILLEGAL_STATE_ERROR, "0");
    prop.put(ILLEGAL_ARGUMENT_ERROR, "0");
    prop.put(INSTANTIATION_ERROR, "0");

    saveConfig(prop);
}

From source file:Main.java

public static boolean replaceField(String className, String fieldName, Object desObj, Object fieldObj) {
    Field tempField;// w w w .j av  a  2s  .  c  om
    try {
        tempField = Class.forName(className).getDeclaredField(fieldName);
        tempField.setAccessible(true);
        tempField.set(desObj, fieldObj);
        return true;
    } catch (NoSuchFieldException e) {
        // TODO Auto-generated catch block
        Log.i("DEX", "" + e.getMessage());
        // e.printStackTrace();
    } catch (ClassNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalArgumentException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return false;
}

From source file:Main.java

public static boolean isAppAlive(Context context, String packageName) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningAppProcessInfo> processInfos = activityManager.getRunningAppProcesses();
    for (int i = 0; i < processInfos.size(); i++) {
        if (processInfos.get(i).processName.equals(packageName)) {
            Log.i("NotificationLaunch",
                    String.format("the %s is running, isAppAlive return true", packageName));
            return true;
        }//from   www.  ja va2  s. c  o  m
    }
    Log.i("NotificationLaunch", String.format("the %s is not running, isAppAlive return false", packageName));
    return false;
}

From source file:Main.java

public static void ZLog(String Tag, int Message) {
    if (BaatnaLog)
        Log.i(Tag, Message + "");
}