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 boolean LargerMemoryMode(Context context) {
    if (true) {/*w w  w. ja va 2 s .c  o m*/
        if (memsize == -1.0f) {
            memsize = getMemeorySize(context);
            Log.d("memory", "size = " + memsize);
        }
        return memsize >= 2.75f;//1.75, just for x7
    }

    return true;
}

From source file:Main.java

static public String getMacAddress(Context context, ConnectivityManager connMananger) {
    Log.d(TAG, "getMacAddress");

    String macAddress = "";

    NetworkInfo info = connMananger.getActiveNetworkInfo();
    if (info != null && info.isConnected()) {
        int type = info.getType();

        Log.d(TAG, "connected type = " + type + " name " + info.getTypeName());

        if (type == ConnectivityManager.TYPE_WIFI) {
            WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
            WifiInfo wifiInfo = wifiManager.getConnectionInfo();
            macAddress = wifiInfo.getMacAddress();
        } else if (type == ConnectivityManager.TYPE_ETHERNET || type == ConnectivityManager.TYPE_MOBILE) {
            String addressFileName = "/sys/class/net/eth0/address";
            File addressFile = new File(addressFileName);
            Log.d(TAG, "1");

            if (addressFile.exists()) {
                Log.d(TAG, "2");
                macAddress = readString(addressFile);
                Log.d(TAG, macAddress);/*from w  ww.j av  a 2 s.com*/
            } else {
                addressFileName = "/sys/class/net/eth1/address";
                addressFile = new File(addressFileName);
                if (addressFile.exists()) {
                    macAddress = readString(addressFile);
                    Log.d(TAG, macAddress);
                }
            }
        } else {
            //other type;
        }
    }
    return macAddress;
}

From source file:Main.java

public static int findBackFacingCamera() {
    int cameraId = INVALID_CAMERA_ID;
    // Search for the front facing camera
    int numberOfCameras = Camera.getNumberOfCameras();
    for (int i = 0; i < numberOfCameras; i++) {
        Camera.CameraInfo info = new Camera.CameraInfo();
        Camera.getCameraInfo(i, info);/*  w  w w  .  j  a va2s .com*/
        if (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK) {
            Log.d("CameraUtil", "Camera found");
            cameraId = i;
            break;
        }
    }
    return cameraId;
}

From source file:Main.java

/**
 * Method to trim log messages for debug
 *
 * @param TAG     Tag for the message//  w ww  .  ja v  a 2s  . c  o  m
 * @param message Message to log
 */
public static void d(String TAG, String message) {
    int maxLogSize = 1000;
    for (int index = 0; index <= message.length() / maxLogSize; index++) {
        int start = index * maxLogSize;
        int end = (index + 1) * maxLogSize;
        end = end > message.length() ? message.length() : end;
        Log.d(TAG, message.substring(start, end));
    }
}

From source file:Main.java

public static int findFrontFacingCamera() {
    int cameraId = INVALID_CAMERA_ID;
    // Search for the front facing camera
    int numberOfCameras = Camera.getNumberOfCameras();
    for (int i = 0; i < numberOfCameras; i++) {
        Camera.CameraInfo info = new Camera.CameraInfo();
        Camera.getCameraInfo(i, info);/*from  ww  w  .  j  a  v  a2  s .  c om*/
        if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
            Log.d("CameraUtil", "Camera found");
            cameraId = i;
            break;
        }
    }
    return cameraId;
}

From source file:Main.java

/** Retrieve a type-face. Does not load twice, uses lazy loading. */
public static Typeface getTypeface(Context context, String name) {
    // ensure the global context is used. just in case.
    context = context.getApplicationContext();
    Log.d(TAG, "name=" + name);
    if (TYPEFACE_CACHE.containsKey(name)) {
        return TYPEFACE_CACHE.get(name);
    }/*from ww  w  .  j  a  v  a2  s.co  m*/

    Typeface typeface = Typeface.createFromAsset(context.getAssets(), name);

    if (typeface != null) {
        TYPEFACE_CACHE.put(name, typeface);
    }

    return typeface;
}

From source file:Main.java

public static Bitmap loadBitmap(String url) {
    Log.d(TAG, "Start Load Url : " + url);
    //Bitmap bitmap = null;
    InputStream in = null;/*from w ww. j  a  va 2  s .  c om*/
    BufferedOutputStream out = null;
    try {
        in = new BufferedInputStream(new URL(url).openStream());
        final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
        int nRead;
        byte[] data = new byte[16384];

        while ((nRead = in.read(data, 0, data.length)) != -1) {
            dataStream.write(data, 0, nRead);
        }
        dataStream.flush();
        final byte[] newData = dataStream.toByteArray();
        BitmapFactory.Options options = new BitmapFactory.Options();
        bitmapResult = BitmapFactory.decodeByteArray(newData, 0, newData.length, options);
    } catch (IOException e) {
        Log.e("My fault", "Could not load Bitmap from: " + url);
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {

                e.printStackTrace();
            }
        }
        if (out != null) {
            try {
                out.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    return bitmapResult;
}

From source file:Main.java

public static Camera.Size findClosetPreviewSize(Camera camera, Point preferSize) {
    int preferX = preferSize.x;
    int preferY = preferSize.y;
    Camera.Parameters parameters = camera.getParameters();
    List<Camera.Size> allSupportSizes = parameters.getSupportedPreviewSizes();
    Log.d(TAG, "all support preview size: " + dumpPreviewSizeList(allSupportSizes));
    int minDiff = Integer.MAX_VALUE;
    int index = 0;
    for (int i = 0; i < allSupportSizes.size(); i++) {
        Camera.Size size = allSupportSizes.get(i);
        int x = size.width;
        int y = size.height;

        int diff = Math.abs(x - preferX) + Math.abs(y - preferY);
        if (diff < minDiff) {
            minDiff = diff;//w  w w  .j  av  a  2 s .  c o  m
            index = i;
        }
    }

    Camera.Size size = allSupportSizes.get(index);
    return size;
}

From source file:Main.java

public static boolean runRootCommand(Context context, String command) {
    Process process = null;//from   w  ww  . ja v  a  2  s .c o m
    DataOutputStream os = null;
    try {
        process = Runtime.getRuntime().exec("su");
        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

/**
 * @param imgName//from ww  w.  j  a va  2s . c  o m
 * @return
 */
public static Bitmap getBitmapFromPath(String imgName) {
    String sExtendSdcardDir = "";
    String sAppRoot = "";

    String sdcardRoot = Environment.getExternalStorageDirectory() == null ? ""
            : Environment.getExternalStorageDirectory().getAbsolutePath();
    Log.d("Tiny", "sdcardRoot --" + sdcardRoot);

    if (sdcardRoot != null) {
        sExtendSdcardDir = sdcardRoot;
        sAppRoot = sExtendSdcardDir.concat("/TINY");
    }

    String sCache = sAppRoot.concat("/cache");

    File file = new File(sCache);
    if (!file.exists()) {
        file.mkdirs();
    }
    Log.d("Tiny", "file path --" + file.getAbsolutePath());

    File image = new File(file.getAbsolutePath(), imgName);
    BitmapFactory.Options bmOptions = new BitmapFactory.Options();
    Bitmap bitmap = BitmapFactory.decodeFile(image.getAbsolutePath(), bmOptions);
    return bitmap;
}