Example usage for android.util Log w

List of usage examples for android.util Log w

Introduction

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

Prototype

public static int w(String tag, Throwable tr) 

Source Link

Usage

From source file:Main.java

public static boolean isConnAvailAndNotRoaming(Context context) {

    ConnectivityManager conMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);

    if (conMgr.getActiveNetworkInfo() != null && conMgr.getActiveNetworkInfo().isAvailable()
            && conMgr.getActiveNetworkInfo().isConnected()) {

        if (!conMgr.getActiveNetworkInfo().isRoaming())
            return true;
        else//from w  w  w  . j a  v  a 2s.c  o  m
            return false;
    } else {
        Log.w(TAG, "Internet Connection NOT Present");
        return false;
    }
}

From source file:Main.java

static int calculateOrientation(Activity activity, int cameraId) {
    if (cameraId == NO_CAMERA)
        return 0;

    DisplayMetrics dm = new DisplayMetrics();
    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    int cameraRotationOffset = info.orientation;
    Log.w(TAG, "cameraRotationOffset = " + cameraRotationOffset);

    activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
    int currentScreenRotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    Log.w(TAG, "currentScreenRotation = " + currentScreenRotation);

    int degrees = 0;
    switch (currentScreenRotation) {
    case Surface.ROTATION_0:
        degrees = 0;//from   w  ww  .  j a va  2  s. c  om
        break;
    case Surface.ROTATION_90:
        degrees = 90;
        break;
    case Surface.ROTATION_180:
        degrees = 180;
        break;
    case Surface.ROTATION_270:
        degrees = 270;
        break;
    }
    Log.w(TAG, "degrees = " + degrees);

    int orientation;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        orientation = (cameraRotationOffset + degrees) % 360;
        orientation = (360 - orientation) % 360;
    } else {
        orientation = (cameraRotationOffset - degrees + 360) % 360;
    }
    Log.w(TAG, "orientation = " + orientation);

    return orientation;
}

From source file:Main.java

static int calculateOrientationHint(Activity activity, int cameraId) {
    if (cameraId == NO_CAMERA)
        return 0;

    DisplayMetrics dm = new DisplayMetrics();
    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraId, info);
    int cameraRotationOffset = info.orientation;
    Log.w(TAG, "OrientationHint cameraRotationOffset = " + cameraRotationOffset);

    activity.getWindowManager().getDefaultDisplay().getMetrics(dm);
    int currentScreenRotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    Log.w(TAG, "OrientationHint currentScreenRotation = " + currentScreenRotation);

    int degrees = 0;
    switch (currentScreenRotation) {
    case Surface.ROTATION_0:
        degrees = 0;/*from  www.  j a v a  2 s. c  o  m*/
        break;
    case Surface.ROTATION_90:
        degrees = 90;
        break;
    case Surface.ROTATION_180:
        degrees = 180;
        break;
    case Surface.ROTATION_270:
        degrees = 270;
        break;
    }
    Log.w(TAG, "OrientationHint degrees = " + degrees);

    int orientation;
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        orientation = (cameraRotationOffset + degrees) % 360;
        if (degrees != 0) {
            orientation = (360 - orientation) % 360;
        }
    } else {
        orientation = (cameraRotationOffset - degrees + 360) % 360;
    }
    Log.w(TAG, "orientationHint = " + orientation);

    return orientation;
}

From source file:Main.java

public static byte[] encryptMsg(String msg, RSAPublicKeySpec pubKeySpec) {
    if (msg != null && pubKeySpec != null && !msg.isEmpty()) {
        try {/*from w w  w .  j av  a 2s  . c o m*/
            Log.w(TAG, "msg is: " + msg + " with length " + msg.length());
            KeyFactory fact = KeyFactory.getInstance("RSA");

            PublicKey pubKey = fact.generatePublic(pubKeySpec);

            // TODO encrypt the message and send it
            // Cipher cipher = Cipher.getInstance("RSA/None/NoPadding");
            Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
            // Cipher cipher =
            // Cipher.getInstance("RSA/None/OAEPWithSHA1AndMGF1Padding",
            // "BC");
            cipher.init(Cipher.ENCRYPT_MODE, pubKey);
            Log.d(TAG, "cipher block size is " + cipher.getBlockSize());
            byte[] msgByteArray = msg.getBytes();
            byte[] cipherData = new byte[cipher.getOutputSize(msgByteArray.length)];
            cipherData = cipher.doFinal(msgByteArray);
            Log.d(TAG, "output size is " + cipher.getOutputSize(msgByteArray.length));
            Log.d(TAG, "is the measurement already broken into chunks here? " + (new String(cipherData)));
            return cipherData;

        } catch (NoSuchAlgorithmException e) {
            Log.e(TAG, "RSA algorithm not available", e);
        } catch (InvalidKeySpecException e) {
            Log.e(TAG, "", e);
        } catch (NoSuchPaddingException e) {
            Log.e(TAG, "", e);
        } catch (InvalidKeyException e) {
            Log.e(TAG, "", e);
        } catch (BadPaddingException e) {
            Log.e(TAG, "", e);
        } catch (IllegalBlockSizeException e) {
            Log.e(TAG, "", e);
        } catch (Exception e) {
            Log.e(TAG, "", e);
        } /*
           * catch (NoSuchProviderException e) { Log.e(TAG, "", e); }
           */
    }
    return null;
}

From source file:Main.java

public static void setCookie(Context context, String url) {
    FileInputStream in = null;/*from   w  ww.  j  av a 2s.  co m*/
    try {
        in = context.openFileInput(TAXICOOKIE_FILE);
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    }
    if (in == null) {
        Log.w(TAG, "saveCookie: Cannot open file: " + TAXICOOKIE_FILE);
    }

    BufferedReader reader = new BufferedReader(new InputStreamReader(in));
    String cookieStr = null;
    try {
        cookieStr = reader.readLine();
        reader.close();
    } catch (IOException e) {
        e.printStackTrace();
    }

    Log.d(TAG, "cookieStr: " + cookieStr);
    if (cookieStr == null) {
        return;
    }

    CookieSyncManager.createInstance(context);
    CookieManager cookieManager = CookieManager.getInstance();
    cookieManager.removeSessionCookie();
    cookieManager.setCookie(url, cookieStr);
    CookieSyncManager.getInstance().sync();
}

From source file:Main.java

public static List grabFiles() {
    List<String> tFileList = new ArrayList<String>();
    String p = Environment.getExternalStorageDirectory().getAbsolutePath() + "/nexsight/";
    File f = new File(p);

    Log.d(TAG, "Read from " + p);
    File[] files = f.listFiles();
    files = flipArray(files);//from   ww  w. j av  a  2s  . co  m
    if (files != null) {
        for (int i = 0; i < files.length; i++) {
            File file = files[i];
            tFileList.add(file.getPath());
        }
    } else {
        Log.w(TAG, "nothing found in " + p);
    }

    return tFileList;
}

From source file:Main.java

public static boolean executeAsRoot(String command) {
    try {/*w  ww . ja v  a  2  s .  c  om*/

        Process suProcess = Runtime.getRuntime().exec("su");
        DataOutputStream os = new DataOutputStream(suProcess.getOutputStream());

        os.writeBytes(command + "\n");
        os.flush();
        Log.d("ROOT", command);

        os.writeBytes("exit\n");
        os.flush();

        try {
            int suProcessRet = suProcess.waitFor();
            if (255 != suProcessRet)
                return true;
            else
                return false;
        } catch (Exception ex) {
            Log.w("ROOT-ERROR", ex);
        }
    } catch (IOException ex) {
        Log.w("ROOT", "Can't get root access", ex);
    } catch (SecurityException ex) {
        Log.w("ROOT", "Can't get root access", ex);
    } catch (Exception ex) {
        Log.w("ROOT", "Error executing internal operation", ex);
    }
    return false;
}

From source file:Main.java

public static void logEglErrorAsWarning(String tag, String function, int error) {
    Log.w(tag, formatEglError(function, error));
}

From source file:Main.java

public static int getTotalHeightofListView(ListView listView) {
    ListAdapter mAdapter = listView.getAdapter();
    if (mAdapter == null) {
        return 0;
    }/*from ww  w . j ava 2 s. c  o  m*/
    int totalHeight = 0;
    for (int i = 0; i < mAdapter.getCount(); i++) {
        View mView = mAdapter.getView(i, null, listView);
        mView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
                View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
        //mView.measure(0, 0);
        totalHeight += mView.getMeasuredHeight();
        Log.w("HEIGHT" + i, String.valueOf(totalHeight));
    }
    ViewGroup.LayoutParams params = listView.getLayoutParams();
    params.height = totalHeight + (listView.getDividerHeight() * (mAdapter.getCount() - 1));
    listView.setLayoutParams(params);
    listView.requestLayout();
    return params.height;
}

From source file:Main.java

public static void debug(Object msg) {
    if (debug) {
        Log.w("AQuery", msg + "");
    }
}