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

private static Bitmap readScaledBitmapFromUri(Uri photoUri, Context context, int width, int height)
        throws FileNotFoundException, IOException {
    Log.i("Photo Editor", "Read Scaled Bitmap: " + width + " " + height);
    InputStream is;/*from ww w  .  j av a 2  s .  co  m*/
    Bitmap srcBitmap;
    is = context.getContentResolver().openInputStream(photoUri);
    if (width > MAX_IMAGE_DIMENSION || height > MAX_IMAGE_DIMENSION) {
        float ratio = calculateScaleRatio(width, height);
        Log.i("Photo Editor", "Scaled Bitmap: " + ratio);
        srcBitmap = readRoughScaledBitmap(is, ratio);
        ratio = calculateScaleRatio(srcBitmap.getWidth(), srcBitmap.getHeight());
        srcBitmap = scaleBitmap(srcBitmap, ratio);
    } else {
        Log.i("Photo Editor", "NOT Scaled Bitmap ");
        srcBitmap = BitmapFactory.decodeStream(is);
    }
    is.close();
    return srcBitmap;
}

From source file:Main.java

/**
 * Sends a request to the Activity instance to process the messages.
 * //from   www . jav  a 2  s. c o m
 * @param context The application context.
 */
public static void processMessages(Context context) {
    Log.i(TAG, "processMessages");
    Intent intent = new Intent(PROCESS_MESSAGES_ACTION);
    context.sendBroadcast(intent);
}

From source file:Main.java

public static String execRootCmd(String[] cmds) {
    String result = "";
    DataOutputStream dos = null;//from   w  ww.  java2  s . com
    DataInputStream dis = null;

    try {
        Process p = Runtime.getRuntime().exec("su");
        dos = new DataOutputStream(p.getOutputStream());
        dis = new DataInputStream(p.getInputStream());

        for (String cmd : cmds) {
            Log.i("CmdUtils", cmd);
            dos.writeBytes(cmd + "\n");
            dos.flush();
        }
        dos.writeBytes("exit\n");
        dos.flush();
        String line;
        while ((line = dis.readLine()) != null) {
            Log.d("result", line);
            result += line;
        }
        p.waitFor();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (dos != null) {
            try {
                dos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        if (dis != null) {
            try {
                dis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    return result;
}

From source file:Main.java

public static int execRootCmdForExitCode(String[] cmds) {
    int result = -1;
    DataOutputStream dos = null;/* w ww  .jav  a  2  s. c o  m*/
    DataInputStream dis = null;

    try {
        Process p = Runtime.getRuntime().exec("su");
        dos = new DataOutputStream(p.getOutputStream());
        dis = new DataInputStream(p.getInputStream());

        for (String cmd : cmds) {
            Log.i("CmdUtils", cmd);
            dos.writeBytes(cmd + "\n");
            dos.flush();
        }
        dos.writeBytes("exit\n");
        dos.flush();
        String line;
        while ((line = dis.readLine()) != null) {
            Log.d("result", line);
        }
        p.waitFor();
        result = p.exitValue();
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (dos != null) {
            try {
                dos.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        if (dis != null) {
            try {
                dis.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    return result;
}

From source file:Main.java

/**
 * Sends a request to the Activity instance to process the messages.
 * /*from   w  ww.  j av  a  2 s.co m*/
 * @param context The application context.
 */
public static void processMessages(Context context) {
    Log.i(TAG, "processMessages()");
    Intent intent = new Intent(PROCESS_MESSAGES_ACTION);
    context.sendBroadcast(intent);
}

From source file:Main.java

private static void log(String tag, int level, String msg, Throwable tr) {
    if (isLog) {//from   ww w .j  a v  a  2s. c  o m
        switch (level) {
        case Log.VERBOSE:
            if (tr == null) {
                Log.v(tag, msg);
            } else {
                Log.v(tag, msg, tr);
            }
            break;
        case Log.INFO:
            if (tr == null) {
                Log.i(tag, msg);
            } else {
                Log.i(tag, msg, tr);
            }
            break;
        case Log.DEBUG:
            if (tr == null) {
                Log.d(tag, msg);
            } else {
                Log.d(tag, msg, tr);
            }
            break;
        case Log.WARN:
            if (tr == null) {
                Log.w(tag, msg);
            } else {
                Log.w(tag, msg, tr);
            }
            break;
        case Log.ERROR:
            if (tr == null) {
                Log.e(tag, msg, tr);
            } else {
                Log.e(tag, msg, tr);
            }
            break;
        }
    }
}

From source file:Main.java

/**
 * Get a random number within a given range;
 *//*from  ww  w .  ja va2 s  . c om*/
public static int getRandomInt(int min, int max) throws Exception {

    int ret;
    int range = max - min;

    ret = (int) (Math.random() * min) + range;

    Log.i(TAG, String.format("Generate an integer value between %d and %d: %d", min, max, ret));

    return ret;
}

From source file:Main.java

public static String getVideo2gifCommand(long start, long length, int frame, String sourcePath, String outPath,
        int width, int height) {
    StringBuilder command = new StringBuilder("-ss ");
    command.append(start);//from   w w w  . java  2s  .c om
    command.append(" -t ");
    command.append(length);
    command.append(" -i ");
    command.append(sourcePath);
    command.append(" -s ");
    command.append(width + "x" + height);
    command.append(" -f ");
    command.append("gif");
    command.append(" -r ");
    command.append(frame);
    command.append(" ");
    command.append(outPath);
    Log.i("broncho", "command = " + command.toString());
    return command.toString();
}

From source file:Main.java

public static boolean writeFile(String filePath, String fileName, String content, boolean append) {
    FileWriter fileWriter = null;
    boolean result = false;
    if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) {
        try {/*from   w  w  w  .  ja  va 2s.  co  m*/

            File file = new File(filePath);
            if (!file.exists()) {
                file.mkdirs();
            }
            Log.i("file", filePath);
            fileWriter = new FileWriter(filePath + fileName, append);
            fileWriter.write(content);
            result = true;
        } catch (Exception e) {
            e.printStackTrace();
            Log.i("file", e.toString());
        } finally {
            if (fileWriter != null) {
                try {
                    fileWriter.close();
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
    return result;
}

From source file:Main.java

public static void LOGI(final String tag, String message) {
    Log.i(tag, message);
}