Example usage for android.util Log e

List of usage examples for android.util Log e

Introduction

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

Prototype

public static int e(String tag, String msg, Throwable tr) 

Source Link

Document

Send a #ERROR log message and log the exception.

Usage

From source file:Main.java

/**
 * Builds map from list of strings/*  www  . ja v a2 s . c om*/
 *
 * @param args key-value pairs for build a map. Must be a multiple of 2
 * @return Result map. If args not multiple of 2, last argument will be ignored
 */
public static Map<String, Object> mapFrom(Object... args) {
    if (args.length % 2 != 0) {
        Log.w("VKUtil", "Params must be paired. Last one is ignored");
    }
    LinkedHashMap<String, Object> result = new LinkedHashMap<String, Object>(args.length / 2);
    for (int i = 0; i + 1 < args.length; i += 2) {
        if (!(args[i] instanceof String))
            Log.e("VK SDK", "Error while using mapFrom",
                    new InvalidParameterSpecException("Key must be string"));
        result.put((String) args[i], args[i + 1]);
    }
    return result;
}

From source file:Main.java

public static String getBuildString() {

    String strValue = null;/*from  ww  w.  ja  v  a 2  s .  c  o m*/
    BufferedReader birReader = null;

    try {

        Process p = Runtime.getRuntime().exec("getprop ro.modversion");
        birReader = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
        strValue = birReader.readLine();
        birReader.close();

    } catch (IOException e) {
        Log.e("HelperFunctions", "Unable to read property", e);
    } finally {

        if (birReader != null) {

            try {

                birReader.close();

            } catch (IOException e) {
                Log.e("HelperFunctions", "Exception while closing the file", e);
            }

        }

    }

    return strValue;

}

From source file:Main.java

public static String getLocalIP() {
    try {// w w w . java  2  s  . c o m
        for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en
                .hasMoreElements();) {
            NetworkInterface intf = en.nextElement();
            for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
                InetAddress inetAddress = enumIpAddr.nextElement();
                if (!inetAddress.isLoopbackAddress()) {
                    return inetAddress.getHostAddress();
                }
            }
        }
    } catch (SocketException ex) {
        Log.e("bevelop", null, ex);
    }
    return "";
}

From source file:Main.java

public static int findProcessId(String command) {
    int procId = -1;

    try {//ww w.j  a v a  2  s  . c  om
        procId = findProcessIdWithPidOf(command);

        if (procId == -1) {
            procId = findProcessIdWithPS(command);
        }
    } catch (Exception e) {
        try {
            procId = findProcessIdWithPS(command);
        } catch (Exception e2) {
            Log.e(TAG, "Unable to get proc id for command: " + URLEncoder.encode(command), e2);
        }
    }

    return procId;
}

From source file:Main.java

public static File copyAssets(Context context, String fileName) {
    AssetManager assetManager = context.getAssets();
    File outFile = null;/*from  w ww  .  ja  v  a2  s.  c  om*/
    InputStream in = null;
    OutputStream out = null;
    try {
        in = assetManager.open(fileName);
        // copy file path
        outFile = new File(context.getExternalFilesDir(null), fileName);
        out = new FileOutputStream(outFile);
        copyFile(in, out);
    } catch (IOException e) {
        Log.e("tag", "Failed to copy asset file: " + fileName, e);
    } finally {
        if (in != null) {
            try {
                in.close();
            } catch (IOException e) {
                // NOOP
            }
        }
        if (out != null) {
            try {
                out.close();

            } catch (IOException e) {
                // NOOP
            }
        }

    }
    return outFile;
}

From source file:Main.java

public static byte[] bitmapDecode(Bitmap bmp) throws IOException {
    if (bmp != null && bmp.isRecycled())
        return null;
    ByteArrayOutputStream out = new ByteArrayOutputStream();

    if (bmp == null) {
        // Resources res=context.getResources();
        // bmp=BitmapFactory.decodeResource(res,R.drawable.icon);
        // System.out.println("bitmapDecode@CDBPersistent----exception bmp is null,use default book");
        return null;
    }//  w  ww .jav  a2 s .c om

    bmp.compress(Bitmap.CompressFormat.PNG, 10, out);

    byte[] array = null;
    try {
        array = out.toByteArray();
    } catch (OutOfMemoryError e) {
        Log.e("arrayoom", "", e);
    }
    return array;
}

From source file:Main.java

public static Bitmap getBitmapFromUri(Uri uri, Context context) {
    ParcelFileDescriptor parcelFileDescriptor = null;
    try {/*from w  w  w  .  j av a  2s.c  o m*/

        parcelFileDescriptor = context.getContentResolver().openFileDescriptor(uri, "r");
        FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
        Bitmap image = BitmapFactory.decodeFileDescriptor(fileDescriptor);
        parcelFileDescriptor.close();
        return image;
    } catch (Exception e) {
        Log.e(TAG, "Failed to load image.", e);
        return null;
    } finally {
        try {
            if (parcelFileDescriptor != null) {
                parcelFileDescriptor.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
            Log.e(TAG, "Error closing ParcelFile Descriptor");
        }
    }
}

From source file:Main.java

private static void copy(File srcFile, File targetFile) throws IOException {
    FileChannel src = null, dst = null;
    try {//from   ww w.  j  a  va  2  s. co  m
        if (srcFile.exists() && (!targetFile.exists() || targetFile.delete())) {
            src = new FileInputStream(srcFile).getChannel();
            dst = new FileOutputStream(targetFile).getChannel();
            dst.transferFrom(src, 0, src.size());
            src.close();
            dst.close();
        }
    } finally {
        try {
            if (src != null)
                src.close();
        } catch (IOException e) {
            Log.e("DIARY", "Failed to close resource.", e);
        }
        try {
            if (dst != null)
                src.close();
        } catch (IOException e) {
            Log.e("DIARY", "Failed to close resource.", e);
        }
    }
}

From source file:Main.java

public static void LogE(String msg, Exception e) {
    Log.e(mLogTag, msg, e);
    e.printStackTrace();
}

From source file:Main.java

@SuppressWarnings("deprecation")
public static void alertDialog(final Context context, final int mensagem) {
    try {/*from   ww w.  j  a  va  2  s .c o m*/
        AlertDialog dialog = new AlertDialog.Builder(context).setTitle(
                //               context.getString(R.string.app_name)).setMessage(mensagem).create();
                "Teste").setMessage(mensagem).create();
        dialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                return;
            }
        });
        dialog.show();
    } catch (Exception e) {
        Log.e(TAG, e.getMessage(), e);
    }
}