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 void writeLifeLogCountInFile(int walking, int running, int vehicle, int bicycle, String filename)
        throws IOException {
    Date date = new Date();
    BufferedWriter writer = null;
    File dir = new File(Environment.getExternalStorageDirectory() + "/LifeLog");
    Log.d("Directory PATH", dir.getAbsolutePath());
    boolean flag = dir.mkdir();
    Log.d("Directory created?", "" + flag);
    File file = new File(dir.getAbsolutePath(), filename);
    if (file.exists() == false) {
        file.createNewFile();/*from   w w  w .  ja v a  2s  .c o m*/
        writer = new BufferedWriter(new FileWriter(file, true));
        writer.write("Date,Walking,Running,Bicycle,Vehicle");
        writer.newLine();
        writer.write(date.toString() + "," + walking + "," + running + "," + bicycle + "," + vehicle);
        writer.newLine();
    } else {
        writer = new BufferedWriter(new FileWriter(file, true));
        writer.write(date.toString() + "," + walking + "," + running + "," + bicycle + "," + vehicle);
        writer.newLine();
        Log.d("Appended", "True");
    }
    writer.flush();
    writer.close();

}

From source file:Main.java

public static File getAlbumFolder(String albumName) {
    File folder = new File(Environment.getExternalStorageDirectory() + File.separator + albumName);
    if (!folder.exists()) {
        folder.mkdir();/*w w w.  j  a  v  a2  s .c o m*/
        try {
            new File(folder, ".yesmedia").createNewFile();
        } catch (Exception e) {
            Log.d(TAG, "[AirImagePickerUtils] exception = " + e.getMessage());
            Log.d(TAG, "[AirImagePickerUtils] Exiting didSavePictureInGallery (failed)");
            return null;
        }
    }
    return folder;
}

From source file:Main.java

/**
 * Checks network availability//from   w w w. j  a va  2s .com
 * 
 * @param context
 * @return
 */
public static boolean isNetworkAvailable(Context context) {
    Log.v(TAG, "isNetworkAvailable called.");
    ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

    if (cm.getActiveNetworkInfo() == null) {
        Log.d(TAG, "no active network info found.");
        return false;
    }

    Log.v(TAG, "active network info found.");
    return cm.getActiveNetworkInfo().isConnectedOrConnecting();
}

From source file:Main.java

public static final String replaceRegexAll(String fileContent, String from, String to, boolean isRegex,
        boolean caseSensitive) {
    if (!isRegex) {
        Log.d(from, to);
        from = from.replaceAll(SPECIAL_CHAR_PATTERNSTR, "\\\\$1");
        to = to.replaceAll(SPECIAL_CHAR_PATTERNSTR, "\\\\$1");
        Log.d(from, to);//from  ww  w .j  a  va 2 s .c om
    }
    //System.out.println(fileContent);
    Pattern p = null;
    if (!caseSensitive) {
        p = Pattern.compile(from, Pattern.CASE_INSENSITIVE);
        //fileContent = fileContent.replaceAll("(?i)"+from, to);
    } else {
        p = Pattern.compile(from, Pattern.UNICODE_CASE);
        //fileContent = fileContent.replaceAll(from, to);
    }
    fileContent = p.matcher(fileContent).replaceAll(to);
    //System.out.println(fileContent);
    return fileContent;
}

From source file:Main.java

/** Check if this device has a camera */
private static boolean checkCameraHardware(Context context) {
    if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) {
        // this device has a camera
        return true;
    } else {/*from   w ww  .  ja  v  a2  s  . c  om*/
        // no camera on this device
        Log.d(TAG, "no camera on this device");
        return false;
    }
}

From source file:Main.java

public static File getOutputMediaFile(int type, Context c) {
    File mediaStorageDir = new File(c.getApplicationContext().getExternalFilesDir(null).getAbsolutePath());
    if (!mediaStorageDir.exists()) {
        if (!mediaStorageDir.mkdirs()) {
            Log.d("MyCameraApp", "failed to create directory");
            return null;
        }//from   ww  w .ja v  a  2 s  .c om
    }

    // 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_AUDIO) {
        mediaFile = new File(mediaStorageDir.getPath() + File.separator + "VID_" + timeStamp + ".3gp");
    } else {
        return null;
    }

    return mediaFile;
}

From source file:Main.java

public static int getGeoHash(double lat, double lng) {
    if (lat == 0.0 && lng == 0.0)
        return 0;

    double latHash = (lat + 180) / LATLON_SECTION;
    double lngHash = (lng + 180) / LATLON_SECTION;
    int latHashRounded = (int) Math.round(latHash);
    int lngHashRounded = (int) Math.round(lngHash);

    int hash = latHashRounded * 10000 + lngHashRounded;

    Log.d(TAG, "HotspotDbHelper getGeoHash for lat: " + lat + " lon: " + lng + " is " + hash);
    return hash;/*from www.java2 s  .c o  m*/
}

From source file:Main.java

public static boolean smallMemoryMode(Context context) {
    if (true) {/*from  ww  w . j ava2s  .c  o  m*/
        if (memsize == -1.0f) {
            memsize = getMemeorySize(context);
            Log.d("memory", "size = " + memsize);
        }
        return memsize < 0.9f;//1.75, just for x7
    }

    return true;
}

From source file:Main.java

public static void add(File dexFile, File optimizedDir, PathClassLoader paramPathClassLoader) {
    try {//from www. ja  va  2  s  .  c  o  m
        Class<?> dexPathListClass = Class.forName("dalvik.system.DexPathList");
        Log.d("vivekwassan", "dexFile.getAbsolutePath() :" + dexFile.getAbsolutePath());
        Log.d("vivekwassan", "optimizedDir :" + optimizedDir.getAbsolutePath());
        Constructor<?> constructor = dexPathListClass.getConstructor(ClassLoader.class, String.class,
                String.class, File.class);
        Log.d("vivekwassan", "fine 22");
        Object dexPathList = constructor.newInstance(paramPathClassLoader, dexFile.getAbsolutePath(), null,
                optimizedDir);
        Log.d("vivekwassan", "fine 33");
        Object localObject = joinArrays(getDexElements(getPathList(paramPathClassLoader)),
                getDexElements(dexPathList));
        Log.d("vivekwassan", "fine 44");
        setDexElements(getPathList(paramPathClassLoader), localObject);
        Log.d("vivekwassan", "fine 55");
    } catch (Exception e) {
        Log.e("ClassLoaderInjector", "Error", e);
    }
}

From source file:Main.java

private static boolean compare(PackageInfo apkInfo, Context context) {
    if (apkInfo == null) {
        return false;
    }//from   w  w w . j a  v  a  2s.c  o  m
    String localPackage = context.getPackageName();
    if (apkInfo.packageName.equals(localPackage)) {
        try {
            PackageInfo packageInfo = context.getPackageManager().getPackageInfo(localPackage, 0);
            Log.d("aa", "apkInfo.versionCode: " + apkInfo.versionCode + "-----packageInfo.versionCode:"
                    + packageInfo.versionCode);
            if (apkInfo.versionCode > packageInfo.versionCode) {
                return true;
            }
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
    }
    return false;
}