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

/**
 * Called when a connection to the beacon GATT server has been established.
 *///from w  w w .j  av  a2s.  co  m
private static void onConnectedToNearbyBeaconGattServer() {
    Log.i(TAG, "Connected to GATT server.");
    mBluetoothGatt.discoverServices();
}

From source file:Main.java

public static void setInvertColor(Camera.Parameters parameters) {
    if (Camera.Parameters.EFFECT_NEGATIVE.equals(parameters.getColorEffect())) {
        Log.i(TAG, "Negative effect already set");
        return;//from  w  w  w . j av  a  2s. c om
    }
    String colorMode = findSettableValue("color effect", parameters.getSupportedColorEffects(),
            Camera.Parameters.EFFECT_NEGATIVE);
    if (colorMode != null) {
        parameters.setColorEffect(colorMode);
    }
}

From source file:Main.java

/**
 * get all <uses-permission> tags included under <manifest>
 * /*from   w  ww  . j  a  va 2s  . com*/
 * @param context
 */
public static void getAllAppPermissions(Context context) {
    PackageManager pm = context.getPackageManager();
    PackageInfo packageInfo;
    try {
        // Array of all <uses-permission> tags included under <manifest>, or
        // null if there were none.
        packageInfo = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_PERMISSIONS);
        String permissions[] = packageInfo.requestedPermissions;

        if (permissions != null) { // to list permission
            for (String permission : permissions) {
                Log.i("4A", "permission:" + permission);
            }
        }

    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:Main.java

/**
 * Vibrate if we can / are allowed to.//from  w w w.  j a  v  a 2  s .co  m
 */
public static void vibrate(@Nullable Vibrator vibrator, int milliseconds) {
    if (vibrator == null) {
        Log.i(TAG, "Not vibrating; no vibration support / vibrator not set up");
        return;
    }

    try {
        vibrator.vibrate(milliseconds);
        Log.d(TAG, milliseconds + "ms vibration started...");
    } catch (SecurityException e) {
        Log.i(TAG, "Not vibrating: " + e.getMessage());
    }
}

From source file:Main.java

public static void setVideoStabilization(Camera.Parameters parameters) {
    if (parameters.isVideoStabilizationSupported()) {
        if (parameters.getVideoStabilization()) {
            Log.i(TAG, "Video stabilization already enabled");
        } else {/* ww  w.j a va 2s. c  om*/
            Log.i(TAG, "Enabling video stabilization...");
            parameters.setVideoStabilization(true);
        }
    } else {
        Log.i(TAG, "This device does not support video stabilization");
    }
}

From source file:Main.java

public static void unpairMac(String macToRemove) {
    BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
    Set<BluetoothDevice> bondedDevices = bluetoothAdapter.getBondedDevices();
    try {//from   www.  j  a v  a2s . c  o  m
        Class<?> btDeviceInstance = Class.forName(BluetoothDevice.class.getCanonicalName());
        Method removeBondMethod = btDeviceInstance.getMethod("removeBond");
        boolean cleared = false;
        for (BluetoothDevice bluetoothDevice : bondedDevices) {
            String mac = bluetoothDevice.getAddress();
            if (mac.equals(macToRemove)) {
                removeBondMethod.invoke(bluetoothDevice);
                Log.i(TAG, "Cleared Pairing");
                cleared = true;
                break;
            }
        }

        if (!cleared) {
            Log.i(TAG, "Not Paired");
        }
    } catch (Throwable th) {
        Log.e(TAG, "Error pairing", th);
    }
}

From source file:Main.java

public static Bitmap decodeFile(String fPath) {
    BitmapFactory.Options opts = new BitmapFactory.Options();
    opts.inJustDecodeBounds = true;//from  w w w.j a  v  a2  s. co  m
    opts.inDither = false; // Disable Dithering mode
    opts.inPurgeable = true; // Tell to gc that whether it needs free
    opts.inInputShareable = true; // Which kind of reference will be used to
    BitmapFactory.decodeFile(fPath, opts);
    final int REQUIRED_SIZE = 200;
    int scale = 1;
    if (opts.outHeight > REQUIRED_SIZE || opts.outWidth > REQUIRED_SIZE) {
        final int heightRatio = Math.round((float) opts.outHeight / (float) REQUIRED_SIZE);
        final int widthRatio = Math.round((float) opts.outWidth / (float) REQUIRED_SIZE);
        scale = heightRatio < widthRatio ? heightRatio : widthRatio;//
    }
    Log.i("scale", "scal =" + scale);
    opts.inJustDecodeBounds = false;
    opts.inSampleSize = scale;
    Bitmap bm = BitmapFactory.decodeFile(fPath, opts).copy(Config.ARGB_8888, false);
    return bm;
}

From source file:Main.java

/** my code to convert from List<Double> to double[]
 *
 *///  w  w w.  j a  va  2 s.  c om
public static float[] toFloatArray(List<Float> lf) {
    float[] results = new float[lf.size()];
    int i = 0;
    for (Float f : lf) {
        results[i++] = (f != null ? f : 0);
    }
    Log.i("TAG", "float conversion results " + Arrays.toString(results));
    return results;
}

From source file:Main.java

/**
 * IMPORTANT: USE ONLY TEMPORARY!! DELETE THE FUNCTION AFTER DEBUGGING,
 * BECAUSE THE INPUTSTREAM WILL BE DESTROYED AFTER (WILL BE EMPTY) Writes
 * the content of the input stream to a <code>String<code>.
 *///from   ww  w .  j ava  2  s  .  c  o  m
public static String toString(InputStream inputStream) throws IOException {
    String string;
    StringBuilder outputBuilder = new StringBuilder();
    try {
        if (inputStream != null) {
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
            while (null != (string = reader.readLine())) {
                outputBuilder.append(string).append('\n');
            }
        }
    } catch (Exception e) {
        Log.i(I, "Problem: toString(InputStream). Cannot convert.");
    }

    return outputBuilder.toString();
}

From source file:Main.java

public static boolean deleteDirectory(String fileName) {
    boolean status;
    SecurityManager checker = new SecurityManager();

    if (!fileName.equals("")) {

        File path = Environment.getExternalStorageDirectory();
        File newPath = new File(path.toString() + fileName);
        checker.checkDelete(newPath.toString());
        if (newPath.isDirectory()) {
            String[] listfile = newPath.list();
            // delete all files within the specified directory and then
            // delete the directory
            try {
                for (int i = 0; i < listfile.length; i++) {
                    File deletedFile = new File(newPath.toString() + "/" + listfile[i].toString());
                    deletedFile.delete();
                }//from w  w  w.  ja va 2s .co m
                newPath.delete();
                Log.i("DirectoryManager deleteDirectory", fileName);
                status = true;
            } catch (Exception e) {
                e.printStackTrace();
                status = false;
            }

        } else
            status = false;
    } else
        status = false;
    return status;
}