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

@SuppressWarnings("unused")
private static void saveImage(byte[] data) {
    File pictureFile = getOutputMediaFile(MEDIA_TYPE_IMAGE);
    if (pictureFile == null) {
        Log.d(TAG, "Error creating media file, check storage permissions");
        return;// ww w  .ja  v a2  s  .c om
    }

    try {
        FileOutputStream fos = new FileOutputStream(pictureFile);
        fos.write(data);
        fos.close();
    } catch (FileNotFoundException e) {
        Log.d(TAG, "File not found: " + e.getMessage());
    } catch (IOException e) {
        Log.d(TAG, "Error accessing file: " + e.getMessage());
    }
}

From source file:Main.java

public static int getResourceIdByName(Context context, String className, String name) {
    int id = 0;/*from  ww w.  ja va2  s.co m*/
    if (context == null) {
        return id;
    } else {
        String packageName = context.getPackageName();

        try {
            String var10 = packageName + ".R$" + className;
            Class desireClass = Class.forName(var10);
            if (desireClass != null) {
                id = desireClass.getField(name).getInt(desireClass);
            }
        } catch (ClassNotFoundException var7) {
            Log.d("dou361", "ClassNotFoundException: class=" + className + " fieldname=" + name);
        } catch (IllegalArgumentException var8) {
            Log.d("dou361", "IllegalArgumentException: class=" + className + " fieldname=" + name);
        } catch (SecurityException var9) {
            Log.d("dou361", "SecurityException: class=" + className + " fieldname=" + name);
        } catch (IllegalAccessException var101) {
            Log.d("dou361", "IllegalAccessException: class=" + className + " fieldname=" + name);
        } catch (NoSuchFieldException var11) {
            Log.d("dou361", "NoSuchFieldException: class=" + className + " fieldname=" + name);
        }

        return id;
    }
}

From source file:Main.java

public static File getOutputMediaFile(int type, String folderName) {
    File mediaStorageDir = new File(
            Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), folderName);
    if (!mediaStorageDir.exists()) {
        if (!mediaStorageDir.mkdirs()) {
            Log.d(folderName, "failed to create directory");
            return null;
        }/* w  w  w. j  av  a 2 s.c o m*/
    }
    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 if (type == MEDIA_TYPE_AUDIO) {
        mediaFile = new File(mediaStorageDir.getPath() + File.separator + "AUD_" + timeStamp + ".3gp");
    } else {
        return null;
    }
    return mediaFile;
}

From source file:Main.java

public static int[] readBinIntArray(String dir, String fileName, int size) {
    int x;// www  .  jav  a  2 s. co m
    int i = 0;
    int[] tab = new int[size];
    File sdLien = Environment.getExternalStorageDirectory();
    File inFile = new File(sdLien + File.separator + dir + File.separator + fileName);
    Log.d(TAG, "path of file : " + inFile);
    if (!inFile.exists()) {
        throw new RuntimeException("File doesn't exist");
    }
    DataInputStream in = null;
    try {
        in = new DataInputStream(new FileInputStream(inFile));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    try {
        x = in.readInt();
        while (true) {
            tab[i] = x;
            i++;
            x = in.readInt();
        }
    } catch (EOFException e) {
        try {
            Log.d(TAG, "close");
            in.close();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (in != null) {
            try { //free ressources
                Log.d(TAG, "close");
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    return tab;
}

From source file:Main.java

public static float[] readBinFloat(String dir, String fileName, int size) {
    float x;//ww w.  j ava2  s  .  c  om
    int i = 0;
    float[] tab = new float[size];
    File sdLien = Environment.getExternalStorageDirectory();
    File inFile = new File(sdLien + File.separator + dir + File.separator + fileName);
    Log.d(TAG, "path of file : " + inFile);
    if (!inFile.exists()) {
        throw new RuntimeException("File doesn't exist");
    }
    DataInputStream in = null;
    try {
        in = new DataInputStream(new FileInputStream(inFile));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    try {
        x = in.readFloat();
        while (i < size) {
            tab[i] = x;
            i++;
            x = in.readFloat();
        }
    } catch (EOFException e) {
        try {
            Log.d(TAG, "close");
            in.close();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (in != null) {
            try { //free ressources
                Log.d(TAG, "close");
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    return tab;
}

From source file:Main.java

static void d(String tag, String format, Object... args) {
    Log.d(tag, String.format(format, args));
}

From source file:Main.java

public static float[] readBinTextureArray(String dir, String fileName, int size) {
    float x;/*w  ww . j a va  2 s .c o  m*/
    int i = 0;
    float[] tab = new float[size];
    File sdLien = Environment.getExternalStorageDirectory();
    File inFile = new File(sdLien + File.separator + dir + File.separator + fileName);
    Log.d(TAG, "path of file : " + inFile);
    if (!inFile.exists()) {
        throw new RuntimeException("File doesn't exist");
    }
    DataInputStream in = null;
    try {
        in = new DataInputStream(new FileInputStream(inFile));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    try {
        x = in.readFloat(); // convert here for OpenGl
        while (true) {
            tab[i] = x / 255.0f;
            i++;
            x = in.readFloat(); // convert here for OpenGl
        }
    } catch (EOFException e) {
        try {
            Log.d(TAG, "close");
            in.close();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (in != null) {
            try { //free ressources
                Log.d(TAG, "close");
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    return tab;
}

From source file:Main.java

private static List<Intent> addIntentsToList(Context context, List<Intent> list, Intent intent) {
    List<ResolveInfo> resInfo = context.getPackageManager().queryIntentActivities(intent, 0);
    for (ResolveInfo resolveInfo : resInfo) {
        String packageName = resolveInfo.activityInfo.packageName;
        Intent targetedIntent = new Intent(intent);
        targetedIntent.setPackage(packageName);
        list.add(targetedIntent);/* w w w  . j a v  a2  s .  c  o m*/
        Log.d(TAG, "Intent: " + intent.getAction() + " package: " + packageName);
    }
    return list;
}

From source file:Main.java

public static float[] readBinShapeArray(String dir, String fileName, int size) {
    float x;/*from w w w. j a v  a  2s  .co m*/
    int i = 0;
    float[] tab = new float[size];

    File sdLien = Environment.getExternalStorageDirectory();
    File inFile = new File(sdLien + File.separator + dir + File.separator + fileName);
    Log.d(TAG, "path of file : " + inFile);
    if (!inFile.exists()) {
        throw new RuntimeException("File doesn't exist");
    }
    DataInputStream in = null;
    try {
        in = new DataInputStream(new FileInputStream(inFile));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    try {
        //read first x
        x = in.readFloat();
        while (true) {
            tab[i] = x;
            i++;
            x = in.readFloat();
        }
    } catch (EOFException e) {
        try {
            Log.d(TAG, "close");
            in.close();
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (in != null) {
            try { //free ressources
                Log.d(TAG, "close");
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
    return tab;
}

From source file:Main.java

public static String getPrimaryAccountEmail(Context context) {
    AccountManager accountManager = AccountManager.get(context);
    Account[] accounts = accountManager.getAccountsByType("com.google");
    if (accounts == null || accounts.length == 0) {
        Log.w(LOG_PREFIX, "Could not find name of primary google account. Returning null");
        return null;
    } else {//from   w w  w.  ja  v  a 2s .  c  o m
        String name = accounts[0].name;
        Log.d(LOG_PREFIX, "Found " + accounts.length + " google accounts. Returning name:" + name);
        return name;
    }
}