Example usage for android.util Log i

List of usage examples for android.util Log i

Introduction

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

Prototype

public static int i(String tag, String msg) 

Source Link

Document

Send an #INFO log message.

Usage

From source file:Main.java

public static Bitmap getAndSetBitmapFromNet(String urlPath) {

    Bitmap bm = null;/* ww  w .j  a v a  2 s.  com*/

    if (urlPath != null) {
        try {
            BufferedInputStream bis = new BufferedInputStream(new URL(urlPath).openStream(), 1024);
            final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
            BufferedOutputStream out = new BufferedOutputStream(dataStream, 1024);
            copy(bis, out);
            out.flush();
            final byte[] data = dataStream.toByteArray();
            bm = BitmapFactory.decodeByteArray(data, 0, data.length);
            Log.i(I, "data.length: " + data.length);
            out.close();
            dataStream.close();
            bis.close();
            bm = processBitmap(bm);
        } catch (IOException e) {
            Log.i(I, "URL Connection or Bitmap processing Exception");
            e.printStackTrace();
        }
    }
    return bm;
}

From source file:Main.java

/**
 * @brief      log utility/*  ww  w . ja  v a2 s .  com*/
 */
static private void log(String format, Object arg1, Object arg2, Object arg3) {
    if (enableLog)
        Log.i(TAG, String.format(format, arg1, arg2, arg3));
}

From source file:Main.java

public static void setZoom(Camera.Parameters parameters, double targetZoomRatio) {
    if (parameters.isZoomSupported()) {
        Integer zoom = indexOfClosestZoom(parameters, targetZoomRatio);
        if (zoom == null) {
            return;
        }// w  ww  . ja va2 s  . c  o m
        if (parameters.getZoom() == zoom) {
            Log.i(TAG, "Zoom is already set to " + zoom);
        } else {
            Log.i(TAG, "Setting zoom to " + zoom);
            parameters.setZoom(zoom);
        }
    } else {
        Log.i(TAG, "Zoom is not supported");
    }
}

From source file:Main.java

public static void showLog(String tag, String msg) {
    if (isDebug && !TextUtils.isEmpty(msg)) {
        if (TextUtils.isEmpty(tag))
            tag = mTag;/*from w  w w . j  a  va2  s.  c  om*/
        StackTraceElement[] stackTraceElement = Thread.currentThread().getStackTrace();
        int currentIndex = -1;
        for (int i = 0; i < stackTraceElement.length; i++) {
            if (stackTraceElement[i].getMethodName().compareTo("showLog") == 0) {
                currentIndex = i + 1;
                break;
            }
        }
        if (currentIndex >= 0) {
            String fullClassName = stackTraceElement[currentIndex].getClassName();
            String className = fullClassName.substring(fullClassName.lastIndexOf(".") + 1);
            String methodName = stackTraceElement[currentIndex].getMethodName();
            String lineNumber = String.valueOf(stackTraceElement[currentIndex].getLineNumber());

            Log.i(tag, msg + "\n  ---->at " + className + "." + methodName + "(" + className + ".java:"
                    + lineNumber + ")");
        } else {
            Log.i(tag, msg);
        }
    }
}

From source file:Main.java

public static RSAPublicKeySpec getRecipientsPublicKey(String contactNum, Context context) {
    Log.w(TAG, "retrieving public key for contact " + contactNum);
    SharedPreferences prefs = context.getSharedPreferences(contactNum, Context.MODE_PRIVATE);

    String pubMod = prefs.getString(PREF_PUBLIC_MOD, DEFAULT_PREF);
    String pubExp = prefs.getString(PREF_PUBLIC_EXP, DEFAULT_PREF);
    Log.w(TAG, "the public modulus is " + pubMod + " and exponent is " + pubExp + " for " + contactNum);
    // String recipient = prefs.getString(PREF_RECIPIENT_NUM, DEFAULT_PREF);
    if (!pubMod.isEmpty() && !pubExp.isEmpty()) {
        Log.i(TAG, "great! public key found for " + contactNum + " with modulus " + pubMod + " and exponent "
                + pubExp);//from w  ww  .  j  a  va  2  s  .  c o m
        byte[] pubModBA = Base64.decode(pubMod, Base64.DEFAULT);
        byte[] pubExpBA = Base64.decode(pubExp, Base64.DEFAULT);
        BigInteger pubModBI = new BigInteger(1, pubModBA); // 1 is added as
        // an attempt to
        // deal with
        // com.android.org.bouncycastle.crypto.DataLengthException:
        // input too
        // large for RSA
        // cipher
        BigInteger pubExpBI = new BigInteger(1, pubExpBA);
        Log.i(TAG, "public modulus is " + pubModBI + " and public exponent is " + pubExpBI + " in base 256 "
                + pubModBA + " " + pubExpBA);

        // do I need to catch any exception for the following?
        RSAPublicKeySpec pubKeySpec = new RSAPublicKeySpec(pubModBI, pubExpBI);
        // X509EncodedKeySpec publicKeySpec = new
        // X509EncodedKeySpec(encodedKey);

        return pubKeySpec;
    }
    Log.w(TAG, "recipient's public key not found");
    return null;

}

From source file:Main.java

/**
 * Checks whether a provided answer is correct.
 *
 * @param checkedItems The items that were selected.
 * @param answerIds The actual correct answer ids.
 * @return <code>true</code> if correct else <code>false</code>.
 *//*from w ww .  j av  a  2s  . c o  m*/
public static boolean isAnswerCorrect(SparseBooleanArray checkedItems, int[] answerIds) {
    if (null == checkedItems || null == answerIds) {
        Log.i(TAG, "isAnswerCorrect got a null parameter input.");
        return false;
    }
    for (int answer : answerIds) {
        if (0 > checkedItems.indexOfKey(answer)) {
            return false;
        }
    }
    return checkedItems.size() == answerIds.length;
}

From source file:Main.java

/**
 * Checks whether a provided answer is correct.
 *
 * @param checkedItems The items that were selected.
 * @param answerIds The actual correct answer ids.
 * @return <code>true</code> if correct else <code>false</code>.
 *//*from www  .jav a2 s . c  om*/
public static boolean isAnswerCorrect(SparseBooleanArray checkedItems, int[] answerIds) {
    if (null == checkedItems || null == answerIds) {
        Log.i(TAG, "isAnswerCorrect got a null parameter input.");
        return false;
    }
    for (int answer : answerIds) {
        if (0 > checkedItems.indexOfKey(answer)) {
            return false;
        }
    }
    return true;
}

From source file:Main.java

public static void setMetering(Camera.Parameters parameters) {
    if (parameters.getMaxNumMeteringAreas() > 0) {
        Log.i(TAG, "Old metering areas: " + parameters.getMeteringAreas());
        List<Camera.Area> middleArea = buildMiddleArea(AREA_PER_1000);
        Log.i(TAG, "Setting metering area to : " + toString(middleArea));
        parameters.setMeteringAreas(middleArea);
    } else {/*w w w . java  2  s  .com*/
        Log.i(TAG, "Device does not support metering areas");
    }
}

From source file:Main.java

public static void scanMediaFiles(final Context context, String[] files, String[] mimeTypes) {
    MediaScannerConnection.scanFile(context, files, mimeTypes, new OnScanCompletedListener() {
        @Override//w  ww  .ja v  a2s. co  m
        public void onScanCompleted(String arg0, Uri arg1) {
            Log.i("weitu", "arg0:" + arg0 + ";arg1:" + arg1);
        }
    });
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
public static void setVideoStabilization(Camera.Parameters parameters) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
        if (parameters.isVideoStabilizationSupported()) {
            if (parameters.getVideoStabilization()) {
                Log.i(TAG, "Video stabilization already enabled");
            } else {
                Log.i(TAG, "Enabling video stabilization...");
                parameters.setVideoStabilization(true);
            }/*from ww w . j av a2  s  .c o  m*/
        } else {
            Log.i(TAG, "This device does not support video stabilization");
        }
    } else {
        Log.i(TAG, "This device does not support video stabilization");
    }
}