Example usage for android.util Log v

List of usage examples for android.util Log v

Introduction

In this page you can find the example usage for android.util Log v.

Prototype

public static int v(String tag, String msg) 

Source Link

Document

Send a #VERBOSE log message.

Usage

From source file:Main.java

public static String getCPUMax() {
    String txtInfo = "";
    try {//from   ww  w.jav a2 s  .c  o m
        Process proc = Runtime.getRuntime().exec("cat /proc/cpuinfo");
        InputStream is = proc.getInputStream();
        StringBuilder sb = new StringBuilder();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line = null;
        try {
            while ((line = br.readLine()) != null) {
                Log.v("TestLog", line);
                if (line.indexOf("BogoMIPS") >= 0) {
                    txtInfo = line.substring(8);
                }
            }
        } catch (IOException e) {
            // Log.v("getStringFromInputStream", "------ getStringFromInputStream " + e.getMessage());
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                }
            }
        }
    } catch (IOException e) {
        Log.e("getCpuInfo", "------ getCpuInfo " + e.getMessage());
    }
    return txtInfo;
}

From source file:Main.java

public static String getIMSI(Context context) {
    String imsi = "";
    try {/* w ww  . ja v a  2s  .c om*/
        TelephonyManager phoneManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        imsi = phoneManager.getSubscriberId();
        Log.v(TAG, imsi);
    } catch (Exception e) {
        Log.e(TAG, "getIMSI error!");
        imsi = "";
    }

    if (imsi == null) {
        imsi = "";
    }
    return imsi;
}

From source file:Main.java

public static boolean CheckNetworkConnect(Context context) {
    boolean result = false;
    ConnectivityManager manager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo mobileInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
    NetworkInfo wifiInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
    NetworkInfo ethInfo = manager.getNetworkInfo(ConnectivityManager.TYPE_ETHERNET);
    NetworkInfo activeInfo = manager.getActiveNetworkInfo();
    Log.v("networkInfo", "mobile:" + mobileInfo.isConnected() + "\n" + "wifi:" + wifiInfo.isConnected() + "\n"
            + "eth:" + ethInfo.isConnected() + "\n" + "active:" + activeInfo.getTypeName());
    if (wifiInfo.isConnected() || ethInfo.isConnected()) {
        result = true;//from   w  ww  .  j a v a2 s.  c  om
    }
    return result;
}

From source file:Main.java

public static String encryptData(String password, String plaintextData) throws Exception {
    // Thank you Mr. Nelenkov
    String maybeThisHelps = "http://nelenkov.blogspot.com/2012/04/using-password-based-encryption-on.html";
    Log.v(TAG, maybeThisHelps);
    int iterationCount = 100; //because Polaroid
    int keyLength = 256;
    int saltLength = keyLength;

    SecureRandom random = new SecureRandom();
    byte[] salt = new byte[saltLength];
    random.nextBytes(salt);/*w  w  w. jav  a2 s.  com*/
    KeySpec keySpec = new PBEKeySpec(password.toCharArray(), salt, iterationCount, keyLength);
    SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
    byte[] keyBytes = keyFactory.generateSecret(keySpec).getEncoded();
    SecretKey key = new SecretKeySpec(keyBytes, "AES");

    Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    byte[] iv = new byte[cipher.getBlockSize()];
    random.nextBytes(iv);

    IvParameterSpec ivParams = new IvParameterSpec(iv);
    cipher.init(Cipher.ENCRYPT_MODE, key, ivParams);
    byte[] ciphertext = cipher.doFinal(plaintextData.getBytes("UTF-8"));

    String ivToString = new String(Base64.encode(iv, 0));
    String saltToString = new String(Base64.encode(salt, 0));
    String ciphertextToString = new String(Base64.encode(ciphertext, 0));

    Log.d(TAG, ivToString + "]" + saltToString + "]" + ciphertextToString);
    return (ivToString + "]" + saltToString + "]" + ciphertextToString).replace("\n", "");
}

From source file:Main.java

public static int loadShader(int type, String shaderCode) {
    int shaderHandle = GLES20.glCreateShader(type);

    if (shaderHandle != 0) {
        GLES20.glShaderSource(shaderHandle, shaderCode);
        GLES20.glCompileShader(shaderHandle);

        // Get the compilation status.
        final int[] compileStatus = new int[1];
        GLES20.glGetShaderiv(shaderHandle, GLES20.GL_COMPILE_STATUS, compileStatus, 0);

        // If the compilation failed, delete the shader.
        if (compileStatus[0] == 0) {
            Log.v(TAG, "Shader fail info: " + GLES20.glGetShaderInfoLog(shaderHandle));
            GLES20.glDeleteShader(shaderHandle);
            shaderHandle = 0;/*from  w ww.  j ava2  s  .c om*/
        }
    }

    if (shaderHandle == 0) {
        throw new RuntimeException("Error creating shader " + type);
    }
    return shaderHandle;
}

From source file:Main.java

/**
 * kudos: http://www.jondev.net/articles/Unzipping_Files_with_Android_(Programmatically)
 * @param zipFile//w  w w . j a v a2s . c o  m
 * @param destinationDirectory
 */
public static void unZip(String zipFile, String destinationDirectory) {
    try {
        FileInputStream fin = new FileInputStream(zipFile);
        ZipInputStream zin = new ZipInputStream(fin);
        ZipEntry ze = null;
        while ((ze = zin.getNextEntry()) != null) {
            Log.v("Decompress", "Unzipping " + ze.getName());
            String destinationPath = destinationDirectory + File.separator + ze.getName();
            if (ze.isDirectory()) {
                dirChecker(destinationPath);
            } else {
                FileOutputStream fout;
                try {
                    File outputFile = new File(destinationPath);
                    if (!outputFile.getParentFile().exists()) {
                        dirChecker(outputFile.getParentFile().getPath());
                    }
                    fout = new FileOutputStream(destinationPath);
                    for (int c = zin.read(); c != -1; c = zin.read()) {
                        fout.write(c);
                    }
                    zin.closeEntry();
                    fout.close();
                } catch (Exception e) {
                    // ok for now.
                    Log.v("Decompress", "Error: " + e.getMessage());
                }
            }
        }
        zin.close();
    } catch (Exception e) {
        Log.e("Decompress", "unzip", e);
    }
}

From source file:Main.java

public static byte[] readBytesFromFile(String path) {
    if (path == null || path.trim().length() == 0) {
        return null;
    }//from w  w w .  ja va 2 s.  c o m

    File file = new File(path);

    if (file.exists() && file.isFile()) {
        int filelength = (int) file.length();
        byte[] filecontent = new byte[filelength];
        try {
            FileInputStream in = new FileInputStream(file);
            in.read(filecontent);
            in.close();

        } catch (IOException e) {
            Log.v(TAG, "read file is error");
            return null;
        }
        return filecontent;
    }
    return null;
}

From source file:Main.java

/**
 * Creates a temporary file for storing a photo that will be taken with the
 * camera.//from  w  ww.  j  ava 2s  .  c om
 * 
 * @param context
 *            the application's context
 * @return a Uri that points to the file
 */
public static Uri getPhotoUri(Context context) {
    File photo;
    try {
        // place where to store camera taken picture
        photo = createTemporaryFile("picture", ".jpg", context);
        photo.delete();
    } catch (Exception e) {
        Log.v(TAG, "Can't create file to take picture!");
        return null;
    }

    Uri mImageUri = Uri.fromFile(photo);
    return mImageUri;
}

From source file:Main.java

private static void log(String msg) {
    Log.v(TAG, msg);
}

From source file:Main.java

@SuppressLint("NewApi")
public static void revealView(View toBeRevealed, View frame) {
    try {/*from  w  ww  .  j  a va 2s. com*/
        if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
            // get the center for the clipping circle
            int cx = (frame.getLeft() + frame.getRight()) / 2;
            int cy = (frame.getTop() + frame.getBottom()) / 2;

            // get the final radius for the clipping circle
            int finalRadius = Math.max(frame.getWidth(), frame.getHeight());
            Log.v("INFO", "Radius: " + finalRadius);

            // create the animator for this view (the start radius is zero)
            Animator anim = ViewAnimationUtils.createCircularReveal(toBeRevealed, cx, cy, 0, finalRadius);

            // make the view visible and start the animation
            toBeRevealed.setVisibility(View.VISIBLE);
            anim.start();
        } else {
            toBeRevealed.setVisibility(View.VISIBLE);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}