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

/**
 * Create a File for saving an image or video
 */// w  w  w.  ja  va  2 s. c om
@SuppressLint("SimpleDateFormat")
public static File getOutputMediaFile(int type, Context context) {
    // Create a media file name
    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
    File mediaFile = null;
    if (type == MEDIA_TYPE_IMAGE) {
        File mediaStorageDir = new File(
                Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), "StoryCapture");
        if (!mediaStorageDir.exists()) {
            if (!mediaStorageDir.mkdirs()) {
                Log.d("StoryCapture", "failed to create directory");
                return null;
            }
        }
        mediaFile = new File(mediaStorageDir.getPath() + File.separator + "IMG_" + timeStamp + ".jpg");
    } else if (type == MEDIA_TYPE_AUDIO) {
        String fileName = "AUDIO_" + timeStamp + ".3gp";
        mediaFile = new File(context.getFilesDir(), fileName);
    }
    return mediaFile;
}

From source file:Main.java

public static void printeBackup(Bundle data, String lev) {
    if (!debug) {
        return;/*ww  w  . j  ava 2  s .  c  o m*/
    }
    Log.d("backup", "---- " + lev + " begin ----");
    if (null != data) {
        for (String key : data.keySet()) {
            Object value = data.get(key);
            Log.d("backup", "key = " + key + " , value = " + value);
        }
    }
}

From source file:Main.java

public static boolean upZipFile(File zipFile, String folderPath) throws ZipException, IOException {
    ZipFile zfile = new ZipFile(zipFile);
    Enumeration<? extends ZipEntry> zList = zfile.entries();
    ZipEntry ze = null;//  w  w  w .  java2 s.  c om
    byte[] buf = new byte[1024];
    while (zList.hasMoreElements()) {
        ze = (ZipEntry) zList.nextElement();
        if (ze.isDirectory()) {
            continue;
        }
        Log.d(TAG, "ze.getName() = " + ze.getName());
        OutputStream os = new BufferedOutputStream(
                new FileOutputStream(getRealFileName(folderPath, ze.getName())));
        InputStream is = new BufferedInputStream(zfile.getInputStream(ze));
        int readLen = 0;
        while ((readLen = is.read(buf, 0, 1024)) != -1) {
            os.write(buf, 0, readLen);
        }
        is.close();
        os.close();
    }
    zfile.close();
    return true;
}

From source file:Main.java

public static String getJsonCurrencyObject(String myurl) {
    StringBuilder strBuilder = new StringBuilder();

    try {//from w  ww.  jav  a 2  s  .  c  o  m
        URL url = new URL(myurl);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();

        InputStream inputStream = new BufferedInputStream(connection.getInputStream());

        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
        String line;
        while ((line = reader.readLine()) != null) {
            strBuilder.append(line);
        }
        inputStream.close();

    } catch (MalformedURLException ex) {
        Log.d("HttpURLConnection", "getJsonCurrencyObject: " + ex.getMessage());
    }

    catch (IOException e) {
        Log.d("readJSONFeed", e.getLocalizedMessage());
        e.printStackTrace();
    } catch (Exception ex) {
        Log.d("GeneralException", ex.getMessage());
    }

    return strBuilder.toString();
}

From source file:Main.java

public static void log(Object object, String msg, boolean debug, int level) {
    if (level < CURRENT_DEBUG_LEVEL) {
        return;//  www.j a  v  a 2  s. c om
    } else {
        if (DEBUG && debug) {
            String name = object.getClass().getSimpleName();
            switch (level) {
            case DEBUG_LEVEL_VERBOSE:
                Log.v(TAG, name + ": " + msg);
                break;
            case DEBUG_LEVEL_DEBUG:
                Log.d(TAG, name + ": " + msg);
                break;
            case DEBUG_LEVEL_ERROR:
                Log.e(TAG, name + ": " + msg);
                break;
            default:
                break;
            }
        }
    }
}

From source file:Main.java

public static List<Map<String, String>> ReadPlaylistItemsFromFile(String path, String filename) {

    List<Map<String, String>> results = new ArrayList<Map<String, String>>();

    try {/*ww w .jav  a  2s  .co  m*/
        File fXmlFile = new File(path, filename);
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        Document doc = dBuilder.parse(fXmlFile);
        doc.getDocumentElement().normalize();

        NodeList songList = doc.getElementsByTagName("song");
        Log.d("ReadItemsFromFile", "List Length: " + songList.getLength());

        for (int i = 0; i < songList.getLength(); i++) {

            Node nNode = songList.item(i);
            if (nNode.getNodeType() == Node.ELEMENT_NODE) {
                Element eElement = (Element) nNode;

                HashMap<String, String> mapElement = new HashMap<String, String>();

                mapElement.put("name", eElement.getElementsByTagName("name").item(0).getTextContent());
                mapElement.put("artist", eElement.getElementsByTagName("artist").item(0).getTextContent());
                mapElement.put("startTime",
                        eElement.getElementsByTagName("startTime").item(0).getTextContent());
                mapElement.put("url", eElement.getElementsByTagName("url").item(0).getTextContent());

                results.add(mapElement);
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
    return results;

}

From source file:com.manning.androidhacks.hack023.api.TodoServiceImpl.java

public static List<Todo> fetchTodos()
        throws AuthenticationException, JsonParseException, IOException, AndroidHacksException {
    Log.d(TAG, "Fetching Todo's...");
    String url = AndroidHacksUrlFactory.getInstance().getTodoUrl();
    String response = HttpHelper.getHttpResponseAsString(url, null);
    Gson gson = new Gson();
    List<Todo> lists = gson.fromJson(response, getToken());

    return lists;
}

From source file:Main.java

public static boolean isBuildPropertyAvaliable(Context c, String propName) {
    try {//from w w w.j a v a2 s.  co m
        Process p = runSuCommandAsync(c, "busybox grep \"" + propName + "=\" /system/build.prop");
        try {
            p.waitFor();
            Log.d("Helper", "isBuildPropAvali : exitValue is : " + String.valueOf(p.exitValue()));
            if (p.exitValue() == 0)
                return true;

        } catch (InterruptedException d) {
            Log.e("Helper", "Failed grep build.prop and waiting for process. errcode:" + d.toString());
        }
    } catch (Exception d) {
        Log.e("Helper", "Failed grep build.prop. errcode:" + d.toString());
    }
    return false;
}

From source file:Main.java

public static int loadProgram(final String strVSource, final String strFSource) {
    int iVShader;
    int iFShader;
    int iProgId;//  w  ww. j  ava 2  s. com
    int[] link = new int[1];
    iVShader = loadShader(strVSource, GLES20.GL_VERTEX_SHADER);
    if (iVShader == 0) {
        Log.d("Load Program", "Vertex Shader Failed");
        return 0;
    }
    iFShader = loadShader(strFSource, GLES20.GL_FRAGMENT_SHADER);
    if (iFShader == 0) {
        Log.d("Load Program", "Fragment Shader Failed");
        return 0;
    }

    iProgId = GLES20.glCreateProgram();

    GLES20.glAttachShader(iProgId, iVShader);
    GLES20.glAttachShader(iProgId, iFShader);

    GLES20.glLinkProgram(iProgId);

    GLES20.glGetProgramiv(iProgId, GLES20.GL_LINK_STATUS, link, 0);
    if (link[0] <= 0) {
        Log.d("Load Program", "Linking Failed");
        return 0;
    }
    GLES20.glDeleteShader(iVShader);
    GLES20.glDeleteShader(iFShader);
    return iProgId;
}

From source file:Main.java

public static String[] getClassStaticFieldNames(Class c, Type fieldType, String nameContains) {
    Field[] fields = c.getDeclaredFields();
    List<String> list = new ArrayList<>();
    for (Field field : fields) {
        try {//from w ww .  ja v a  2s  .c  o m
            boolean isString = field.getType().equals(fieldType);
            boolean containsExtra = field.getName().contains(nameContains);
            boolean isStatic = Modifier.isStatic(field.getModifiers());
            if (field.getType().equals(String.class) && field.getName().contains("EXTRA_")
                    && Modifier.isStatic(field.getModifiers()))
                list.add(String.valueOf(field.get(null)));
        } catch (IllegalAccessException iae) {
            Log.d(TAG,
                    "!!!!!!!!!!!! class Static field, illegal access exception message: " + iae.getMessage());
        }
    }
    return list.toArray(new String[list.size()]);
}