Example usage for android.util Log d

List of usage examples for android.util Log d

Introduction

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

Prototype

public static int d(String tag, String msg) 

Source Link

Document

Send a #DEBUG log message.

Usage

From source file:Main.java

private static Intent finishAndRemoveTasks(List<ActivityManager.AppTask> tasksToFinish) {
    Intent removedIntent = null;/*from  w  w  w . ja v  a2  s. com*/
    for (ActivityManager.AppTask task : tasksToFinish) {
        Log.d(TAG, "Removing task with duplicated data: " + task);
        removedIntent = getBaseIntentFromTask(task);
        task.finishAndRemoveTask();
    }
    return removedIntent;
}

From source file:Main.java

public static boolean matchLength(EditText editText, int length) {
    if (nonEmpty(editText)) {
        String content = removeBlankSpace(editText.getText().toString());
        return content.length() == length;
    } else {/* w ww .  j  a v a 2s  .c o m*/
        Log.d("SERI_PAR->Error", "edit text object is null");
        return NO;
    }
}

From source file:Main.java

/**
 *
 * @param act//from  w ww .j  ava  2  s  .  co  m
 * @return
 */
public static RelativeLayout getContainerView(Activity act) {
    // create a new relative layout
    RelativeLayout rl = new RelativeLayout(act);

    // fint the root view of the activity
    ViewGroup fl = (ViewGroup) act.findViewById(android.R.id.content);
    fl = (ViewGroup) fl.getChildAt(0);
    Log.d("DEBUG", "w: " + fl.getWidth() + "h: " + fl.getHeight());

    // Params
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(-1, -1);
    //        new FrameLayout.LayoutParams(-1, -1);
    // add to the root view of the activity
    fl.addView(rl, params);

    return rl;
}

From source file:Main.java

public static boolean tempRunRootCommand(Context context, String command) {
    Process process = null;//from  w  w  w. j ava 2 s  . c o m
    DataOutputStream os = null;
    try {
        process = Runtime.getRuntime().exec("su1");
        os = new DataOutputStream(process.getOutputStream());
        os.writeBytes(command + "\n");
        os.writeBytes("exit\n");
        os.flush();
        process.waitFor();
    } catch (Exception e) {
        Log.d("*** DEBUG ***", "Error - " + e.getMessage());
        return false;
    } finally {
        try {
            if (os != null) {
                os.close();
            }
            process.destroy();
        } catch (Exception e) {

        }
    }
    return true;
}

From source file:Main.java

private static String getSystemProperty(String key, String defaultValue) {
    String value = defaultValue;//ww w  .j a  va 2s .c o m
    try {
        Class<?> clazz = Class.forName("android.os.SystemProperties");
        Method get = clazz.getMethod("get", String.class, String.class);
        value = (String) (get.invoke(clazz, key, ""));
    } catch (Exception e) {
        if (LOGENABLE) {
            Log.d("getSystemProperty", "key = " + key + ", error = " + e.getMessage());
        }
    }

    if (LOGENABLE) {
        Log.d("getSystemProperty", key + " = " + value);
    }
    return value;
}

From source file:Main.java

public static String fixCharCode(String wholeFile) {
    long millis = System.currentTimeMillis();
    Matcher mat = CHAR_CODE_PATTERN.matcher(wholeFile);
    StringBuffer sb = new StringBuffer();
    while (mat.find()) {
        // System.gc();
        mat.appendReplacement(sb, ((char) Integer.parseInt(mat.group(1)) + ""));
    }/* www .j  a  v a2 s  .  com*/
    mat.appendTail(sb);
    Log.d("fix char code time: ", "" + (System.currentTimeMillis() - millis));
    return sb.toString();
}

From source file:Main.java

public static boolean instantExec(Context context, String command) {
    try {//from w w  w . ja va  2  s .  com
        runSuCommand(context, command.toString());
    } catch (Exception e) {
        Toast.makeText(context, "E:ScriptRunner: " + e.getMessage(), Toast.LENGTH_SHORT).show();
        Log.d(LOGTAG, "E:ScriptRunner: " + e.getMessage());
        return false;
    }
    return true;
}

From source file:Main.java

private static int getRotation(Context context, Uri imageUri, boolean isCamera) {
    int rotation;
    if (isCamera) {
        rotation = getRotationFromCamera(context, imageUri);
    } else {/*from  w  w  w . java  2 s  . c  o m*/
        rotation = getRotationFromGallery(context, imageUri);
    }
    Log.d(TAG, "Image rotation: " + rotation);
    return rotation;
}

From source file:Main.java

public static boolean isNetworkOnline(Context context) {
    try {/*w w  w . j  av a2s  .  co m*/
        ConnectivityManager conMan = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        State mobile = conMan.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
        State wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
        Log.d("DEBUG", "mobile: " + mobile + ", wifi: " + wifi);
        if (mobile == NetworkInfo.State.CONNECTED || mobile == NetworkInfo.State.CONNECTING
                || wifi == NetworkInfo.State.CONNECTED || wifi == NetworkInfo.State.CONNECTING) {
            return true;
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}

From source file:Main.java

public static String loadJSONFromAsset(Context context, String fileName) {
    String json = null;//from   w ww  .  j  a  va  2 s  .  c  o  m
    try {
        InputStream is = context.getAssets().open(fileName);
        int size = is.available();
        byte[] buffer = new byte[size];
        is.read(buffer);
        is.close();
        json = new String(buffer, "UTF-8");
    } catch (IOException ex) {
        Log.d(TAG, "Exception Occurred : " + ex.getMessage());
        return null;
    }
    return json;

}