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 byte[] readBytesFromFile(File file) {
    if (file != null && file.exists() && file.isFile()) {
        int filelength = (int) file.length();
        byte[] filecontent = new byte[filelength];
        try {//from   w  w  w.  j a v  a2s. co  m
            FileInputStream in = new FileInputStream(file);
            in.read(filecontent);
            in.close();

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

From source file:Main.java

public static String[] showLocation(Location location) {

    String[] currentLocation = new String[2];

    if (location != null) {
        String lat = Double.toString(location.getLatitude());
        String lng = Double.toString(location.getLongitude());
        Log.v("LAT", "latitude:" + lat);
        Log.v("Longitude", "longitude:" + lng);
        currentLocation[0] = lat;//from  w  ww.  ja v  a2s  .co  m
        currentLocation[1] = lng;
        Log.v("GPS", currentLocation[0] + ":" + currentLocation[1]);
    } else {
        currentLocation[0] = "-1";
        currentLocation[1] = "-1";
        Log.v("LOC", "Location not available.");
    }
    return currentLocation;
}

From source file:Main.java

public static void ask_for_payment(Context context, String payee_id, String annotation, String channel_id,
        String callback_url, int amount) {
    Intent intent = new Intent(CONFIRM_PAYMENT_ACTION);
    intent.putExtra("payee_id", payee_id);
    intent.putExtra("annotation", annotation);
    intent.putExtra("channel_id", channel_id);
    intent.putExtra("callback_url", callback_url);
    intent.putExtra("amount", amount);
    context.sendBroadcast(intent);//from w  w  w. jav  a  2s .c  o  m
    Log.v(LOG_TAG, "send intent to main activity to confirm payment");
}

From source file:Main.java

/**
 * /*from  w  ww.  j a v  a2 s . co m*/
 * @param context
 * @param uri
 *            uri of SCHEME_FILE or SCHEME_CONTENT
 * @return image path; uri will be changed to SCHEME_FILE
 */
public static String uriToImagePath(Context context, Uri uri) {
    if (context == null || uri == null) {
        return null;
    }

    String imagePath = null;
    String uriString = uri.toString();
    String uriSchema = uri.getScheme();
    if (uriSchema.equals(ContentResolver.SCHEME_FILE)) {
        imagePath = uriString.substring("file://".length());
    } else {// uriSchema.equals(ContentResolver.SCHEME_CONTENT)
        ContentResolver resolver = context.getContentResolver();
        Cursor cursor = resolver.query(uri, null, null, null, null);
        if (cursor.getCount() == 0) {
            Log.e(TAG, "Uri(" + uri.toString() + ") not found!");
            return null;
        }
        cursor.moveToFirst();
        imagePath = cursor.getString(1);
        // Change the SCHEME_CONTENT uri to the SCHEME_FILE.
        uri = Uri.fromFile(new File(imagePath));
    }
    Log.v(TAG, "Final uri: " + uri.toString());
    return imagePath;
}

From source file:Main.java

/**
 * Compiles a shader, returning the OpenGL object ID.
 *///from  ww w .  j  a v a 2s .  c  om
private static int compileShader(int type, String shaderCode) {
    // Create a new shader object.
    final int shaderObjectId = glCreateShader(type);

    if (shaderObjectId == 0) {
        if (IS_LOGGING_ON) {
            Log.w(TAG, "Could not create new shader.");
        }

        return 0;
    }

    // Pass in the shader source.
    glShaderSource(shaderObjectId, shaderCode);

    // Compile the shader.
    glCompileShader(shaderObjectId);

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

    if (IS_LOGGING_ON) {
        // Print the shader info log to the Android log output.
        Log.v(TAG, "Results of compiling source:" + "\n" + shaderCode + "\n:"
                + glGetShaderInfoLog(shaderObjectId));
    }

    // Verify the compile status.
    if (compileStatus[0] == 0) {
        // If it failed, delete the shader object.
        glDeleteShader(shaderObjectId);

        if (IS_LOGGING_ON) {
            Log.w(TAG, "Compilation of shader failed.");
            throw new RuntimeException("Compilation of shader failed.");
        }

        return 0;
    }

    // Return the shader object ID.
    return shaderObjectId;
}

From source file:edu.umich.flowfence.testapp.TestQM.java

public static void nop(boolean addTaint) {
    if (addTaint) {
        TaintSet.Builder ts = new TaintSet.Builder();
        ts.addTaint("edu.umich.flowfence.testapp/test");
        Log.v(TAG, "Tainting");
        ((IDynamicAPI) (FlowfenceContext.getInstance().getTrustedAPI("taint"))).invoke("addTaint", ts.build());
    }/*from ww w .ja v a  2 s.  c om*/
}

From source file:Main.java

public static Bitmap resizeBitmap(Bitmap input, int destWidth, int destHeight, int rotation)
        throws OutOfMemoryError {
    int dstWidth = destWidth;
    int dstHeight = destHeight;
    int srcWidth = input.getWidth();
    int srcHeight = input.getHeight();

    if ((rotation == 90) || (rotation == 270)) {
        dstWidth = destHeight;//from w w  w .j a va2s.  c  o m
        dstHeight = destWidth;
    }

    boolean needsResize = false;

    if ((srcWidth > dstWidth) || (srcHeight > dstHeight)) {
        needsResize = true;

        float ratio1 = (float) srcWidth / dstWidth;
        float ratio2 = (float) srcHeight / dstHeight;
        Log.v("dsd", "ratio1:" + ratio1 + " ratio2:" + ratio2);

        if (ratio1 > ratio2) {
            float p = (float) dstWidth / srcWidth;
            dstHeight = (int) (srcHeight * p);
        } else {
            float p = (float) dstHeight / srcHeight;
            dstWidth = (int) (srcWidth * p);
        }
    } else {
        dstWidth = srcWidth;
        dstHeight = srcHeight;
    }

    Log.v("dsd", "dstWidth:" + dstWidth + " dstHeight:" + dstHeight + " srcWidth:" + srcWidth + " srcHeight:"
            + srcHeight);
    if ((needsResize) || (rotation != 0)) {
        Bitmap output = null;
        if (rotation == 0) {
            output = Bitmap.createScaledBitmap(input, dstWidth, dstHeight, true);
        } else {
            Matrix matrix = new Matrix();
            matrix.postScale((float) dstWidth / srcWidth, (float) dstHeight / srcHeight);
            matrix.postRotate(rotation);
            output = Bitmap.createBitmap(input, 0, 0, srcWidth, srcHeight, matrix, true);
        }
        return output;
    }
    return input;
}

From source file:Main.java

/**
 * Compiles a shader, returning the OpenGL object ID.
 *//*from  w ww .j  a  v a2s  .  c  om*/
private static int compileShader(int type, String shaderCode) {
    // Create a new shader object.
    final int shaderObjectId = glCreateShader(type);

    if (shaderObjectId == 0) {
        Log.w(TAG, "Could not create new shader.");
        return 0;
    }

    // Pass in the shader source.
    glShaderSource(shaderObjectId, shaderCode);

    // Compile the shader.
    glCompileShader(shaderObjectId);

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

    // Print the shader info log to the Android log output.
    Log.v(TAG, "Results of compiling source:" + "\n" + shaderCode + "\n:" + glGetShaderInfoLog(shaderObjectId));

    // Verify the compile status.
    if (compileStatus[0] == 0) {
        // If it failed, delete the shader object.
        glDeleteShader(shaderObjectId);
        Log.w(TAG, "Compilation of shader failed.");
        return 0;
    }

    // Return the shader object ID.
    return shaderObjectId;
}

From source file:Main.java

@SuppressLint("NewApi")
public static Bitmap decodeSampledBitmap(Uri uri, int reqWidth, int reqHeight, Activity act) {

    // First decode with inJustDecodeBounds=true to check dimensions
    InputStream is;/*from   w  w w. j a va  2s . c o  m*/
    try {
        is = act.getApplicationContext().getContentResolver().openInputStream(uri);
        final BitmapFactory.Options options = new BitmapFactory.Options();
        options.inJustDecodeBounds = true;
        BitmapFactory.decodeStream(is, null, options);
        is.close(); //consider use is.mark and is.reset instead [TODO]

        // Calculate inSampleSize
        options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight);

        // Decode bitmap with inSampleSize set
        //open input stream again
        is = act.getApplicationContext().getContentResolver().openInputStream(uri);
        options.inJustDecodeBounds = false;
        Bitmap ret = BitmapFactory.decodeStream(is, null, options);
        is.close();
        return ret;
    } catch (FileNotFoundException e) {
        Log.v(TAG, "File not found:" + uri.toString());
        e.printStackTrace();
    } catch (IOException e) {
        Log.v(TAG, "I/O exception with file:" + uri.toString());
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

/**
 * Return a String List representing response from invokeOemRilRequestRaw
 *
 * @param aob byte array response from invokeOemRilRequestRaw
 *//*from   w  w  w  .java  2s  .c  o m*/
public static List<String> unpackListOfStrings(byte aob[]) {

    if (aob.length == 0) {
        Log.v(TAG, "Length = 0");
        return Collections.emptyList();
    }

    int lines = aob.length / CHARS_PER_LINE;

    String[] display = new String[lines];
    for (int i = 0; i < lines; i++) {
        int offset, byteCount;
        offset = i * CHARS_PER_LINE + 2;
        byteCount = 0;

        if (offset + byteCount >= aob.length) {
            Log.e(TAG, "Unexpected EOF");
            break;
        }

        while (aob[offset + byteCount] != 0 && (byteCount < CHARS_PER_LINE)) {
            byteCount += 1;
            if (offset + byteCount >= aob.length) {
                Log.e(TAG, "Unexpected EOF");
                break;
            }
        }
        display[i] = new String(aob, offset, byteCount).trim();
    }

    int newLength = display.length;
    while (newLength > 0 && TextUtils.isEmpty(display[newLength - 1])) {
        newLength -= 1;
    }

    return Arrays.asList(Arrays.copyOf(display, newLength));
}