List of usage examples for android.util Log e
public static int e(String tag, String msg)
From source file:Main.java
public static int getAppVersionCode(Context context) { int appVersionCode = 0; try {//from ww w. j ava 2 s . c om PackageManager manager = context.getPackageManager(); PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0); appVersionCode = info.versionCode; } catch (PackageManager.NameNotFoundException e) { Log.e("SysUtils", e.getMessage()); } return appVersionCode; }
From source file:Main.java
/** * /*from ww w . ja v a 2 s .c o m*/ * @param context * @param uri * uri of SCHEME_FILE or SCHEME_CONTENT * @return image path; uri will be changed to SCHEME_FILE */ public static String uriToImagePath(Context context, Uri uri) { if (context == null || uri == null) { return null; } String imagePath = null; String uriString = uri.toString(); String uriSchema = uri.getScheme(); if (uriSchema.equals(ContentResolver.SCHEME_FILE)) { imagePath = uriString.substring("file://".length()); } else {// uriSchema.equals(ContentResolver.SCHEME_CONTENT) ContentResolver resolver = context.getContentResolver(); Cursor cursor = resolver.query(uri, null, null, null, null); if (cursor.getCount() == 0) { Log.e(TAG, "Uri(" + uri.toString() + ") not found!"); return null; } cursor.moveToFirst(); imagePath = cursor.getString(1); // Change the SCHEME_CONTENT uri to the SCHEME_FILE. uri = Uri.fromFile(new File(imagePath)); } Log.v(TAG, "Final uri: " + uri.toString()); return imagePath; }
From source file:cc.softwarefactory.lokki.android.services.DataService.java
public static void start(Context context) { Log.e(TAG, "start Service called"); if (serviceRunning) { // If service is running, no need to start it again. Log.e(TAG, "Service already running..."); return;/*from w ww . ja v a2s. co m*/ } context.startService(new Intent(context, DataService.class)); }
From source file:Main.java
public static boolean isUriValid(Uri uri, ContentResolver resolver) { if (uri == null) return false; try {/*from ww w. java2 s . co m*/ ParcelFileDescriptor pfd = resolver.openFileDescriptor(uri, "r"); if (pfd == null) { Log.e(TAG, "Fail to open URI. URI=" + uri); return false; } pfd.close(); } catch (IOException ex) { return false; } return true; }
From source file:Main.java
/** * Convert a TS 131.102 image instance of code scheme '11' into Bitmap * @param data The raw data//from w w w.jav a2 s .c o m * @param length The length of image body * @return The bitmap */ public static Bitmap parseToBnW(byte[] data, int length) { int valueIndex = 0; int width = data[valueIndex++] & 0xFF; int height = data[valueIndex++] & 0xFF; int numOfPixels = width * height; int[] pixels = new int[numOfPixels]; int pixelIndex = 0; int bitIndex = 7; byte currentByte = 0x00; while (pixelIndex < numOfPixels) { // reassign data and index for every byte (8 bits). if (pixelIndex % 8 == 0) { currentByte = data[valueIndex++]; bitIndex = 7; } pixels[pixelIndex++] = bitToRGB((currentByte >> bitIndex--) & 0x01); } ; if (pixelIndex != numOfPixels) { Log.e(LOG_TAG, "parse end and size error"); } return Bitmap.createBitmap(pixels, width, height, Bitmap.Config.ARGB_8888); }
From source file:Main.java
public static int[] closetFramerate(Camera.Parameters parameters, float frameRate) { int framerate = (int) (frameRate * 1000); List<int[]> rates = parameters.getSupportedPreviewFpsRange(); int[] bestFramerate = rates.get(0); for (int i = 0; i < rates.size(); i++) { int[] rate = rates.get(i); Log.e(TAG, "supported preview pfs min " + rate[0] + " max " + rate[1]); int curDelta = Math.abs(rate[1] - framerate); int bestDelta = Math.abs(bestFramerate[1] - framerate); if (curDelta < bestDelta) { bestFramerate = rate;//from w w w .j a va 2s . com } else if (curDelta == bestDelta) { bestFramerate = bestFramerate[0] < rate[0] ? rate : bestFramerate; } } return bestFramerate; }
From source file:Main.java
public static String locationToAddress(Location loc, Context context) { try {/*w w w.jav a 2 s .c o m*/ double latitude, longitude; String addressText = ""; geocoder = new Geocoder(context); latitude = loc.getLatitude(); longitude = loc.getLongitude(); List<Address> list = geocoder.getFromLocation(latitude, longitude, 1); if (list != null && list.size() > 0) { Address address = list.get(0); addressText = String.format("%s, %s, %s", address.getMaxAddressLineIndex() > 0 ? address.getAddressLine(0) : "", address.getLocality(), address.getCountryName()); } return addressText; } catch (IOException e) { Log.e(LogDavid, "ERROR:" + e.toString()); return ""; } }
From source file:Main.java
private static Map<UUID, String> readPageNameHashesFromFile(File folder) { Map<UUID, String> map = new HashMap<UUID, String>(); try {//w w w . j a v a2 s . c o m FileInputStream fis = new FileInputStream(folder.getAbsolutePath() + fileName); ObjectInputStream ois = new ObjectInputStream(fis); map = (Map<UUID, String>) ois.readObject(); ois.close(); printMap(); } catch (Exception e) { e.printStackTrace(); Log.e("Read from file", e.toString()); } return map; }
From source file:Main.java
public static void printHexDump(String prefix, @NonNull byte[] data) { List<String> strs = new LinkedList<>(); Log.e("HexDump" + prefix, "========"); String bytes = ""; int i;//from www . j av a 2 s . com for (i = 0; i < data.length; i++) { bytes += String.format("%02x ", data[i]); if (i > 0 && (i + 1) % 32 == 0) { strs.add(bytes); bytes = ""; } } strs.add(bytes); for (int j = 0; j < strs.size(); j++) { Log.e("HexDump" + prefix + ":" + j, strs.get(j)); } }