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 void silentAlarm(Context context) {
    if (player != null) {
        Log.i("AlarmHelper", "silented");
        try {//w  w  w. j a  va2 s .  co  m
            if (player.isLooping()) {
                player.setLooping(false);
            }
            player.pause();
            player.stop();
            player.release();
        } catch (IllegalStateException e) {
            AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
            am.setStreamVolume(AudioManager.STREAM_ALARM, 0, 0);
        }

        // player.setVolume(0, 0);
        AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        am.setStreamVolume(AudioManager.STREAM_ALARM, mUserVolume, 0);
    } else {
        Log.i("AlarmHelper", "ring zero");
        AudioManager am = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
        am.setStreamVolume(AudioManager.STREAM_ALARM, 0, 0);
    }

    if (vibrator != null) {
        vibrator.cancel();
    } else {
        vibrator = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
        vibrator.cancel();
    }
}

From source file:Main.java

public static void hideIM(Context context, EditText et) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm.isActive()) {
        imm.hideSoftInputFromWindow(et.getWindowToken(), 0);
        Log.i("Apputil", "--hide IM--");
    }//  ww w . j  a v a2 s.  com
}

From source file:Main.java

public static void i(String tag, String msg) {
    if (DEBUG) {
        Log.i(tag, msg);
    }
}

From source file:Main.java

public static void erasePreference(Context context, int slot) {
    SharedPreferences.Editor editor = getNotificationSettings(context, slot).edit();
    if (editor == null) {
        Log.i(TAG, "Failed to erase notification from preferences");
        return;/* w ww  .ja v  a 2s .  c  o m*/
    }
    editor.clear();
    boolean committed = editor.commit();

    if (!committed) {
        Log.i(TAG, "Failed to erase notification from preferences");
    }
}

From source file:Main.java

public static String GetHash(byte[] data) {
    MessageDigest md;//  ww  w.  j  a  v a  2  s .  c o  m
    String hash = null;
    try {
        md = MessageDigest.getInstance("MD5");
        hash = new BigInteger(1, md.digest(data)).toString(16);
    } catch (NoSuchAlgorithmException e) {
        Log.i("BMSUtil", "Hashing Error!");
        e.printStackTrace();
    }
    return hash;
}

From source file:Main.java

public static byte[] readFromFile(String fileName, int offset, int len) {
    if (fileName == null) {
        return null;
    }/*  ww  w. j a va  2  s  .  co  m*/

    File file = new File(fileName);
    if (!file.exists()) {
        Log.i(TAG, "readFromFile: file not found");
        return null;
    }

    if (len == -1) {
        len = (int) file.length();
    }

    Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len));

    if (offset < 0) {
        Log.e(TAG, "readFromFile invalid offset:" + offset);
        return null;
    }
    if (len <= 0) {
        Log.e(TAG, "readFromFile invalid len:" + len);
        return null;
    }
    if (offset + len > (int) file.length()) {
        Log.e(TAG, "readFromFile invalid file len:" + file.length());
        return null;
    }

    byte[] b = null;
    try {
        RandomAccessFile in = new RandomAccessFile(fileName, "r");
        b = new byte[len];
        in.seek(offset);
        in.readFully(b);
        in.close();

    } catch (Exception e) {
        Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
        e.printStackTrace();
    }
    return b;
}

From source file:Main.java

public static void printMapBySet(Map map) {
    Set<String> ketSet = map.keySet();
    Iterator<String> iterator = ketSet.iterator();
    while (iterator.hasNext()) {
        String key = iterator.next();
        String value = (String) map.get(key);
        Log.i(TAG, "----key = " + key + ",value = " + value);
    }/*from  w ww  . j  a  v  a2 s . c  o  m*/

}

From source file:Main.java

public static String getParentPath(String path) {
    if (!path.contains(FS)) {
        return FS;
    }/*w w w  .  ja  va  2s  .  co  m*/
    if (path.lastIndexOf(FS) < 2) {
        return FS;
    }
    String pass1 = path.substring(0, path.lastIndexOf(FS));
    pass1 = pass1.substring(0, pass1.lastIndexOf(FS));
    Log.i(ID, "getParentPath: " + path + " -> " + pass1);
    return pass1;
}

From source file:Main.java

public static byte[] readFromFile(String fileName, int offset, int len) {
    if (fileName == null) {
        return null;
    }//from  w  w w . j a  v a2s  .  c  o  m

    File file = new File(fileName);
    if (!file.exists()) {
        Log.i(TAG, "readFromFile: file not found");
        return null;
    }

    if (len == -1) {
        len = (int) file.length();
    }

    Log.d(TAG, "readFromFile : offset = " + offset + " len = " + len + " offset + len = " + (offset + len));

    if (offset < 0) {
        Log.e(TAG, "readFromFile invalid offset:" + offset);
        return null;
    }
    if (len <= 0) {
        Log.e(TAG, "readFromFile invalid len:" + len);
        return null;
    }
    if (offset + len > (int) file.length()) {
        Log.e(TAG, "readFromFile invalid file len:" + file.length());
        return null;
    }

    byte[] b = null;
    try {
        RandomAccessFile in = new RandomAccessFile(fileName, "r");
        b = new byte[len]; //
        in.seek(offset);
        in.readFully(b);
        in.close();

    } catch (Exception e) {
        Log.e(TAG, "readFromFile : errMsg = " + e.getMessage());
        e.printStackTrace();
    }
    return b;
}

From source file:Main.java

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