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

/**
 * Function to start a service./*from   ww w .  j a v a 2 s .c om*/
 *
 * @param cls The service's class.
 */
public static void startService(Class<?> cls, Activity activity) {
    if (!serviceIsRunning(cls, activity)) {
        activity.startService(new Intent(activity, cls));
        Log.d("Utils Service", "Service Started");
    }
}

From source file:Main.java

/**
 * Create file if !exist/*from  ww w .j a v a2s  .c om*/
 * 
 * @param filePath
 *            The absolute file path we need to create
 * 
 * @throws IOException
 *             Input/Output exceptions
 */
public static void createFile(File filePath) {
    if (!filePath.exists()) {
        try {
            filePath.createNewFile();
            Log.d("RDWR", "createFile: " + filePath);
        } catch (IOException e) {
            e.printStackTrace();
            Log.d("RDWR", "CreateFile: " + e.getMessage());
        }
    }
}

From source file:Main.java

public static Bitmap processToteImage(String image_path, Bitmap bm) {
    Bitmap bitmap = null;/*from  w  ww . j a v a  2 s . c  o  m*/
    try {
        ExifInterface exif = new ExifInterface(image_path);
        int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 1);
        Log.d("EXIF", "Exif: " + orientation);
        Matrix matrix = new Matrix();
        if (orientation == 6) {
            matrix.postRotate(90);
        } else if (orientation == 3) {
            matrix.postRotate(180);
        } else if (orientation == 8) {
            matrix.postRotate(270);
        }
        bitmap = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true); // rotating
        // bitmap
    } catch (Exception e) {

    }
    return bitmap;
}

From source file:Main.java

public static final void toastMessage(final Activity activity, final String message, String logLevel) {
    if ("w".equals(logLevel)) {
        Log.w("sdkDemo", message);
    } else if ("e".equals(logLevel)) {
        Log.e("sdkDemo", message);
    } else {//from   w w w. ja v  a  2  s  .  c  om
        Log.d("sdkDemo", message);
    }
    activity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            // TODO Auto-generated method stub
            if (mToast != null) {
                mToast.cancel();
                mToast = null;
            }
            mToast = Toast.makeText(activity, message, Toast.LENGTH_SHORT);
            mToast.show();
        }
    });
}

From source file:Main.java

public static boolean isRunningOn2xOrGreaterScreen(Context context) {
    if (context == null) {
        return false;
    }/*from  w  w w .  ja  v  a 2 s .  com*/
    int density = context.getResources().getDisplayMetrics().densityDpi;
    boolean result = density >= DisplayMetrics.DENSITY_HIGH;
    Log.d(TAG, String.format("Device density is %d, and result of @2x check is %b", density, result));
    return result;
}

From source file:Main.java

public static String getEllipsisedText(TextView textView) {
    try {/*  www.j  av  a2 s  .c om*/
        String text = textView.getText().toString();
        int lines = textView.getLineCount();
        int width = textView.getWidth();
        int len = text.length();

        Log.d("Test", "text-->" + text + "; lines-->" + lines + "; width-->" + width + ";len-->" + len);
        TextUtils.TruncateAt where = TextUtils.TruncateAt.END;
        TextPaint paint = textView.getPaint();

        StringBuffer result = new StringBuffer();

        int spos = 0, cnt, tmp, hasLines = 0;

        while (hasLines < lines - 1) {
            cnt = paint.breakText(text, spos, len, true, width, null);
            if (cnt >= len - spos) {
                result.append(text.substring(spos));
                break;
            }

            tmp = text.lastIndexOf('\n', spos + cnt - 1);

            if (tmp >= 0 && tmp < spos + cnt) {
                result.append(text.substring(spos, tmp + 1));
                spos += tmp + 1;
            } else {
                tmp = text.lastIndexOf(' ', spos + cnt - 1);
                if (tmp >= spos) {
                    result.append(text.substring(spos, tmp + 1));
                    spos += tmp + 1;
                } else {
                    result.append(text.substring(spos, cnt));
                    spos += cnt;
                }
            }

            hasLines++;
        }

        if (spos < len) {
            result.append(TextUtils.ellipsize(text.subSequence(spos, len), paint, (float) width, where));
        }

        return result.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }

    return null;
}

From source file:Main.java

public static void response(OutputStream output, String contentType, String description, String responseText) {
    Log.d(">>>NativeH5",
            " xhr response return start time:" + System.currentTimeMillis() + " responseText:" + responseText);

    PrintWriter pw = new PrintWriter(output);
    pw.println("HTTP/1.1 " + description);
    pw.println("Content-Type: " + contentType);
    pw.println("Date: " + new Date());
    pw.println("Access-Control-Allow-Origin: *");
    pw.println("Content-Length: " + responseText.length());
    pw.println();/*from www  .  j a  v  a 2s  .  c  o  m*/
    pw.println(responseText);
    pw.flush();
    try {
        output.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

/**
 * Convenience wrapper around Log.d to print a debug string as:
 * /*w ww . j ava2  s . c om*/
 * <code>onActivityResult: requestCode = <b>value</b>, resultCode = <b>value</b></code>
 *  
 * @param tag THe calling classes tag
 * @param requestCode the request code used when launching the Activity
 * @param resultCode the result code returned by the Activity
 */
public static void logActivityResult(String tag, int requestCode, int resultCode) {
    Log.d(tag, "onActivityResult: requestCode = " + requestCode + ", resultCode = " + resultCode);
}

From source file:Main.java

public static Point getBitmapSize(String path) {
    BitmapFactory.Options options = new BitmapFactory.Options();
    options.inJustDecodeBounds = true;//  w  ww  .  j  a v  a2 s  .  c om
    decodeFile(path, options);
    int realWidth = options.outWidth;
    int realHeight = options.outHeight;

    Log.d("loadimage", "realWidth: " + realWidth);
    Log.d("loadimage", "realHeight: " + realHeight);

    return new Point(realWidth, realHeight);
}

From source file:Main.java

public static boolean isGpsOn(Context context) {
    boolean result = false;

    final LocationManager manager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);

    try {//from www  .  j  av  a  2  s.  com
        if (manager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
            result = true;
        }
    } catch (IllegalArgumentException e) {
        Log.d("GPS Helper", "Looks like we do not have gps on the device");
    }

    return result;
}