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

public static File getOutputMediaFile(final int type) {
    File mediaStorageDir = new File(
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "Dove");

    //.delete();//from  w w w . j ava 2 s  .  co m
    if (!mediaStorageDir.exists()) {
        if (!mediaStorageDir.mkdirs()) {
            Log.d("MyCameraApp", "failed to create directory");
            return null;
        }
    }

    // Create a media file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    File mediaFile;
    if (type == MEDIA_TYPE_IMAGE) {
        mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");
    } else if (type == MEDIA_TYPE_VIDEO) {
        mediaFile = new File(mediaStorageDir.getPath() + File.separator + "VID_" + timeStamp + ".mp4");
    } else {
        return null;
    }

    return mediaFile;
}

From source file:Main.java

/**
 * Make a network request form ONLINE_LOCATION.
 *//*from  w  w  w .j  a v  a  2s .c om*/
public static boolean makeNetworkCall() {
    try {
        URL url = new URL(ONLINE_LOCATION);
        HttpsURLConnection httpsURLConnection = (HttpsURLConnection) url.openConnection();
        httpsURLConnection.getInputStream();
        Log.d(TAG, "Network call completed.");
        return true;
    } catch (IOException e) {
        Log.e(TAG, "IOException " + e.getMessage());
        return false;
    }
}

From source file:Main.java

private static void print(int mode, final String tag, String msg) {
    if (!isPrint) {
        return;/*from  w w  w. ja v  a 2 s.  c  o m*/
    }
    if (msg == null) {
        Log.e(tag, MSG);
        return;
    }
    switch (mode) {
    case Log.VERBOSE:
        Log.v(tag, msg);
        break;
    case Log.DEBUG:
        Log.d(tag, msg);
        break;
    case Log.INFO:
        Log.i(tag, msg);
        break;
    case Log.WARN:
        Log.w(tag, msg);
        break;
    case Log.ERROR:
        Log.e(tag, msg);
        break;
    default:
        Log.d(tag, msg);
        break;
    }
}

From source file:Main.java

public static int setCameraDisplayOrientation(Activity activity, int cameraId, Camera camera) {
    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    int degrees = 0;
    switch (rotation) {
    case Surface.ROTATION_0:
        degrees = 0;//from   w  w  w .ja v a  2  s.  c o m
        break;
    case Surface.ROTATION_90:
        degrees = 90;
        break;
    case Surface.ROTATION_180:
        degrees = 180;
        break;
    case Surface.ROTATION_270:
        degrees = 270;
        break;
    }

    int result;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        result = (info.orientation + degrees) % 360;
        result = (360 - result) % 360; // compensate the mirror
    } else { // back-facing
        result = (info.orientation - degrees + 360) % 360;
    }
    Log.d(TAG, "camera display orientation: " + result);
    camera.setDisplayOrientation(result);

    return result;
}

From source file:at.bitfire.davdroid.URIUtils.java

public static URI ensureTrailingSlash(URI href) {
    if (!href.getPath().endsWith("/")) {
        try {/*from w  w  w.  ja v  a 2 s  .  c  o  m*/
            URI newURI = new URI(href.getScheme(), href.getAuthority(), href.getPath() + "/", null, null);
            Log.d(TAG, "Appended trailing slash to collection " + href + " -> " + newURI);
            href = newURI;
        } catch (URISyntaxException e) {
        }
    }
    return href;
}

From source file:Main.java

public static Map<Integer, List> getProvince(File file) {

    String sql = "select provinceid ,province from province ";
    SQLiteDatabase db = null;//from   w  ww .j av  a2s  . co m
    Cursor c = null;
    Map<Integer, List> provinceData = new HashMap<Integer, List>();
    //List provinceList = null;
    try {
        db = SQLiteDatabase.openOrCreateDatabase(file, null);
        c = db.rawQuery(sql, null);
        List provinceList1 = new ArrayList();
        List provinceList2 = new ArrayList();
        while (c.moveToNext()) {
            Map provinceMap = new HashMap();
            provinceMap.put(c.getString(1), c.getInt(0));
            provinceList1.add(provinceMap);
            provinceList2.add(c.getString(1));
        }
        provinceData.put(0, provinceList1);
        provinceData.put(1, provinceList2);
    } catch (Exception e) {
        Log.d("WineStock", "getProvince:" + e.getMessage());
    } finally {
        if (c != null) {
            c.close();
        }
        if (db != null) {
            db.close();
        }
    }
    return provinceData;
}

From source file:Main.java

public static void fastBufferFileCopy(File source, File target) {
    BufferedInputStream bis = null;
    BufferedOutputStream bos = null;
    long start = System.currentTimeMillis();
    FileInputStream fis = null;/*  www  .  j av a  2s  .c  o  m*/
    FileOutputStream fos = null;
    long size = source.length();
    try {
        fis = new FileInputStream(source);
        bis = new BufferedInputStream(fis);
        fos = new FileOutputStream(target);
        bos = new BufferedOutputStream(fos);

        byte[] barr = new byte[Math.min((int) size, 1 << 20)];
        int read = 0;
        while ((read = bis.read(barr)) != -1) {
            bos.write(barr, 0, read);
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        close(fis);
        close(fos);
        close(bis);
        close(bos);
    }
    long end = System.currentTimeMillis();

    String srcPath = source.getAbsolutePath();
    Log.d("Copied " + srcPath + " to " + target,
            ", took " + (end - start) / 1000 + " ms, total size " + nf.format(size) + " Bytes, speed "
                    + ((end - start > 0) ? nf.format(size / (end - start)) : 0) + "KB/s");
}

From source file:Main.java

public static void linkify(View view, int widgetId) {
    TextView textview = (TextView) view.findViewById(widgetId);
    if (textview != null) {
        textview.setMovementMethod(LinkMovementMethod.getInstance());
    } else {/* w ww .jav  a  2 s. co  m*/
        Log.d(TAG, "NO " + widgetId);
    }
}

From source file:Main.java

private static void setEndOfWeekToCalendar(Calendar c) {
    // Get First Day of next week so it will be considered until 0 hrs of
    // next week//from www.  j a v a 2s.  c  o  m
    c.set(Calendar.DAY_OF_WEEK, c.getMaximum(Calendar.DAY_OF_WEEK));
    setEndOfDayToCalendar(c);
    Log.d("La Cuenta: ", "Max of Current Week: " + DateFormat.getInstance().format(c.getTime()));
}