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

private static String getIpUnderWifi() {
    WifiManager wifiManager = (WifiManager) mContext.getSystemService(Context.WIFI_SERVICE);
    int ipAddress = wifiManager.getConnectionInfo().getIpAddress();
    Log.w(TAG, "getIp  isWifiConnected  ipaddress=" + ipAddress);
    return String.format("%d.%d.%d.%d", ipAddress & 0xff, ipAddress >> 8 & 0xff, ipAddress >> 16 & 0xff,
            ipAddress >> 24 & 0xff);
}

From source file:Main.java

public static void warn(Object msg, Object msg2) {
    Log.w("AQuery", msg + ":" + msg2);
}

From source file:Main.java

private static byte[] generateEncryptionSecret() {
    try {//from  w  w  w.jav  a  2s  .  c om
        KeyGenerator generator = KeyGenerator.getInstance("AES");
        generator.init(128);

        SecretKey key = generator.generateKey();
        return key.getEncoded();
    } catch (NoSuchAlgorithmException ex) {
        Log.w("keyutil", ex);
        return null;
    }
}

From source file:Main.java

private static String getDeviceId(Context context) {
    TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    String tmDevice = null;// www .  ja  v a 2  s  . c o m
    String tmSerial = null;
    String androidId = null;
    try {
        tmDevice = tm.getDeviceId();
    } catch (Exception e) {
        Log.w(LOG_TAG, e);
    }
    try {
        tmSerial = tm.getSimSerialNumber();
    } catch (Exception e) {
        Log.w(LOG_TAG, e);
    }
    androidId = Secure.getString(context.getContentResolver(), Secure.ANDROID_ID);
    if (tmDevice == null) {
        tmDevice = "";
    }
    if (tmSerial == null) {
        tmSerial = "";
    }
    if (androidId == null) {
        androidId = "";
    }
    UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
    return "lsa-kp" + deviceUuid.toString();
}

From source file:Main.java

@Nullable
private static InputStream getStreamFromUri(Uri selectedImageURI, Context theContext) throws IOException {
    switch (selectedImageURI.getScheme()) {
    case "content":
        return theContext.getContentResolver().openInputStream(selectedImageURI);

    case "file":
        return new FileInputStream(new File(URI.create(selectedImageURI.toString())));

    case "http":
        // Fall through
    case "https":
        final URL url = new URL(selectedImageURI.toString());
        final HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setDoInput(true);/*ww w.  j av a2  s  . c  o m*/
        connection.connect();
        return connection.getInputStream();

    default:
        Log.w(TAG, "getStreamFromUri(): unsupported Uri scheme: " + selectedImageURI.getScheme());
        return null;
    }
}

From source file:Main.java

/**
 * /*from ww w. j  a  v a2 s. co m*/
 * @param context
 * @return
 */
public static boolean isNetworkRoaming(Context context) {
    ConnectivityManager connectivity = (ConnectivityManager) context
            .getSystemService(Context.CONNECTIVITY_SERVICE);
    if (connectivity == null) {
        Log.w(LOG_TAG, "couldn't get connectivity manager");
    } else {
        NetworkInfo info = connectivity.getActiveNetworkInfo();
        if (info != null && info.getType() == ConnectivityManager.TYPE_MOBILE) {
            TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
            if (tm != null && tm.isNetworkRoaming()) {
                Log.d(LOG_TAG, "network is roaming");
                return true;
            } else {
                Log.d(LOG_TAG, "network is not roaming");
            }
        } else {
            Log.d(LOG_TAG, "not using mobile network");
        }
    }
    return false;
}

From source file:Main.java

public static boolean isThemeAppEnabled(Context context) {
    PackageManager pm = context.getPackageManager();
    try {/*w w w  .  j  a  va2  s  . c  o  m*/
        ApplicationInfo info = pm.getApplicationInfo(THEME_APP_PACKAGE_NAME, 0);
        return info.enabled;
    } catch (PackageManager.NameNotFoundException e) {
        Log.w(TAG, "isThemeAppEnabled E=" + e);
        return false;
    }
}

From source file:Main.java

public static Bitmap decodeUrl(URL url) {
    InputStream stream = null;/*from   ww w. j  a  va  2s .c o m*/

    try {
        stream = url.openStream();
    } catch (IOException e) {
        Log.w(LOGTAG, "decodeUrl: IOException downloading " + url);
        return null;
    }

    if (stream == null) {
        Log.w(LOGTAG, "decodeUrl: stream not found downloading " + url);
        return null;
    }

    Bitmap bitmap = decodeStream(stream);

    try {
        stream.close();
    } catch (IOException e) {
        Log.w(LOGTAG, "decodeUrl: IOException closing stream " + url, e);
    }

    return bitmap;
}

From source file:Main.java

public static void cancelMissedCallsNotification(Context context) {
    if (hasModifyPhoneStatePermission(context)) {
        try {/*from  www.ja va 2s.  c  o  m*/
            getTelecomManager(context).cancelMissedCallsNotification();
        } catch (SecurityException e) {
            Log.w(TAG, "TelecomManager.cancelMissedCalls called without permission.");
        }
    }
}

From source file:Main.java

public static void silenceRinger(Context context) {
    if (hasModifyPhoneStatePermission(context)) {
        try {//  www.  j  a v  a 2s .  c o  m
            getTelecomManager(context).silenceRinger();
        } catch (SecurityException e) {
            // Just in case
            Log.w(TAG, "TelecomManager.silenceRinger called without permission.");
        }
    }
}