List of usage examples for android.util Log INFO
int INFO
To view the source code for android.util Log INFO.
Click Source Link
From source file:com.github.tony19.timber.loggly.JsonFormatterTest.java
@Test public void formatIgnoresNullMessage() throws IOException { final String nullMsg = null; final JsonLog log = getLog(Log.INFO, "tag", nullMsg, new RuntimeException()); assertThat(log.message, is(nullValue())); }
From source file:Main.java
public static Point findBestPreviewSizeValue(Camera.Parameters parameters, Point screenResolution) { List<Camera.Size> rawSupportedSizes = parameters.getSupportedPreviewSizes(); if (rawSupportedSizes == null) { Log.w(TAG, "Device returned no supported preview sizes; using default"); Camera.Size defaultSize = parameters.getPreviewSize(); if (defaultSize == null) { throw new IllegalStateException("Parameters contained no preview size!"); }//w ww . j a v a 2 s . c om return new Point(defaultSize.width, defaultSize.height); } // Sort by size, descending List<Camera.Size> supportedPreviewSizes = new ArrayList<>(rawSupportedSizes); Collections.sort(supportedPreviewSizes, new Comparator<Camera.Size>() { @Override public int compare(Camera.Size a, Camera.Size b) { int aPixels = a.height * a.width; int bPixels = b.height * b.width; Log.d(TAG, "compare: camera's height:" + a.height + "camera's width:" + a.width); if (bPixels < aPixels) { return -1; } if (bPixels > aPixels) { return 1; } return 0; } }); if (Log.isLoggable(TAG, Log.INFO)) { StringBuilder previewSizesString = new StringBuilder(); for (Camera.Size supportedPreviewSize : supportedPreviewSizes) { previewSizesString.append(supportedPreviewSize.width).append('x') .append(supportedPreviewSize.height).append(' '); } Log.i(TAG, "Supported preview sizes: " + previewSizesString); } double screenAspectRatio = screenResolution.x / (double) screenResolution.y; // Remove sizes that are unsuitable Iterator<Camera.Size> it = supportedPreviewSizes.iterator(); while (it.hasNext()) { Camera.Size supportedPreviewSize = it.next(); int realWidth = supportedPreviewSize.width; int realHeight = supportedPreviewSize.height; if (realWidth * realHeight < MIN_PREVIEW_PIXELS) { it.remove(); continue; } boolean isCandidatePortrait = realWidth < realHeight; Log.d(TAG, "isCandidatePortrait(realWidth < realHeight): " + isCandidatePortrait); int maybeFlippedWidth = isCandidatePortrait ? realHeight : realWidth; int maybeFlippedHeight = isCandidatePortrait ? realWidth : realHeight; double aspectRatio = maybeFlippedWidth / (double) maybeFlippedHeight; double distortion = Math.abs(aspectRatio - screenAspectRatio); if (distortion > MAX_ASPECT_DISTORTION) { it.remove(); continue; } if (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) { Point exactPoint = new Point(realWidth, realHeight); Log.i(TAG, "Found preview size exactly matching screen size: " + exactPoint); return exactPoint; } } // If no exact match, use largest preview size. This was not a great idea on older devices because // of the additional computation needed. We're likely to get here on newer Android 4+ devices, where // the CPU is much more powerful. if (!supportedPreviewSizes.isEmpty()) { Camera.Size largestPreview = supportedPreviewSizes.get(0); Point largestSize = new Point(largestPreview.width, largestPreview.height); Log.i(TAG, "Using largest suitable preview size: " + largestSize); return largestSize; } // If there is nothing at all suitable, return current preview size Camera.Size defaultPreview = parameters.getPreviewSize(); if (defaultPreview == null) { throw new IllegalStateException("Parameters contained no preview size!"); } Point defaultSize = new Point(defaultPreview.width, defaultPreview.height); Log.i(TAG, "No suitable preview sizes, using default: " + defaultSize); return defaultSize; }
From source file:Main.java
/** * Finds the most optimal size. The optimal size is when possible the same as * the camera resolution, if not is is it the best size between the camera solution and * MIN_SIZE_PIXELS/*from ww w .j a v a 2 s . c o m*/ * @param screenResolution * @param rawSupportedSizes *@param defaultCameraSize @return optimal preview size */ private static Point findBestSizeValue(Point screenResolution, List<Camera.Size> rawSupportedSizes, Camera.Size defaultCameraSize) { if (rawSupportedSizes == null) { Log.w(TAG, "Device returned no supported sizes; using default"); if (defaultCameraSize == null) { throw new IllegalStateException("Parameters contained no size!"); } return new Point(defaultCameraSize.width, defaultCameraSize.height); } // Sort by size, descending List<Camera.Size> supportedSizes = new ArrayList<>(rawSupportedSizes); Collections.sort(supportedSizes, new Comparator<Camera.Size>() { @Override public int compare(Camera.Size a, Camera.Size b) { int aPixels = a.height * a.width; int bPixels = b.height * b.width; if (bPixels > aPixels) { return -1; } if (bPixels < aPixels) { return 1; } return 0; } }); if (Log.isLoggable(TAG, Log.INFO)) { StringBuilder sizesString = new StringBuilder(); for (Camera.Size supportedSize : supportedSizes) { sizesString.append(supportedSize.width).append('x').append(supportedSize.height).append(' '); } Log.i(TAG, "Supported sizes: " + sizesString); } double screenAspectRatio = (double) screenResolution.x / (double) screenResolution.y; // Remove sizes that are unsuitable Iterator<Camera.Size> it = supportedSizes.iterator(); while (it.hasNext()) { Camera.Size supportedSize = it.next(); int realWidth = supportedSize.width; int realHeight = supportedSize.height; if (realWidth * realHeight < MIN_SIZE_PIXELS) { it.remove(); continue; } boolean isCandidatePortrait = realWidth < realHeight; int maybeFlippedWidth = isCandidatePortrait ? realHeight : realWidth; int maybeFlippedHeight = isCandidatePortrait ? realWidth : realHeight; double aspectRatio = (double) maybeFlippedWidth / (double) maybeFlippedHeight; double distortion = Math.abs(aspectRatio - screenAspectRatio); if (distortion > MAX_ASPECT_DISTORTION) { it.remove(); continue; } if (maybeFlippedWidth == screenResolution.x && maybeFlippedHeight == screenResolution.y) { Point exactPoint = new Point(realWidth, realHeight); Log.i(TAG, "Found size exactly matching screen size: " + exactPoint); return exactPoint; } } // If no exact match, use largest size. This was not a great idea on older devices because // of the additional computation needed. We're likely to get here on newer Android 4+ devices, where // the CPU is much more powerful. if (!supportedSizes.isEmpty()) { Camera.Size largestCameraSizes = supportedSizes.get(0); Point largestSize = new Point(largestCameraSizes.width, largestCameraSizes.height); Log.i(TAG, "Using largest suitable size: " + largestSize); return largestSize; } // If there is nothing at all suitable, return current size if (defaultCameraSize == null) { throw new IllegalStateException("Parameters contained no size!"); } Point defaultSize = new Point(defaultCameraSize.width, defaultCameraSize.height); Log.i(TAG, "No suitable sizes, using default: " + defaultSize); return defaultSize; }
From source file:org.dodgybits.shuffle.android.server.sync.SyncAlarmService.java
@Override protected void onHandleIntent(Intent intent) { long lastSyncDate = Preferences.getLastSyncLocalDate(this); long nextSyncDate = Math.max(System.currentTimeMillis() + 5000L, lastSyncDate + SYNC_PERIOD); if (Log.isLoggable(TAG, Log.INFO)) { Log.i(TAG, "Next sync at " + new Date(nextSyncDate)); }//from www . ja v a2 s.co m AlarmManager alarmManager = (AlarmManager) getSystemService(Context.ALARM_SERVICE); Intent syncIntent = new Intent(this, SyncAlarmReceiver.class); PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, syncIntent, PendingIntent.FLAG_UPDATE_CURRENT); alarmManager.setRepeating(AlarmManager.RTC, nextSyncDate, SYNC_PERIOD, pendingIntent); // Release the wake lock provided by the WakefulBroadcastReceiver WakefulBroadcastReceiver.completeWakefulIntent(intent); }
From source file:com.google.android.gcm.demo.logic.quicktest.DownstreamHttpJsonQuickTest.java
@Override public void execute(final Logger logger, final Context context, SimpleArrayMap<Integer, String> params) { final String apiKey = params.get(R.id.home_api_key); final String destination = params.get(R.id.home_destination); logger.log(Log.INFO, context.getText(R.string.quicktest_downstream_http_json).toString()); new AsyncTask<Void, Void, Void>() { @Override/*from www .j a v a2s .c o m*/ protected Void doInBackground(Void... params) { final Message.Builder messageBuilder = new Message.Builder(); GcmServerSideSender sender = new GcmServerSideSender(apiKey, logger); try { String response = sender.sendHttpJsonDownstreamMessage(destination, messageBuilder.build()); MainActivity.showToast(context, R.string.downstream_toast_success, response); } catch (IOException ex) { logger.log(Log.INFO, "Downstream HTTP JSON failed:\nerror: " + ex.getMessage()); MainActivity.showToast(context, R.string.downstream_toast_failure, ex.getMessage()); } return null; } }.execute(); }
From source file:com.github.tony19.timber.loggly.JsonFormatterTest.java
@Test public void formatIgnoresEmptyMessage() throws IOException { final String emptyMsg = ""; final JsonLog log = getLog(Log.INFO, "tag", emptyMsg, new RuntimeException()); assertThat(log.message, is(nullValue())); }
From source file:com.irccloud.android.RemoteInputService.java
@Override protected void onHandleIntent(Intent intent) { boolean success = false; String sk = getSharedPreferences("prefs", 0).getString("session_key", ""); if (intent != null && sk != null && sk.length() > 0) { final String action = intent.getAction(); if (ACTION_REPLY.equals(action)) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput != null || intent.hasExtra("reply")) { Crashlytics.log(Log.INFO, "IRCCloud", "Got reply from RemoteInput"); String reply = remoteInput != null ? remoteInput.getCharSequence("extra_reply").toString() : intent.getStringExtra("reply"); if (reply.length() > 0 && !reply.contains("\n/") && (!reply.startsWith("/") || reply.toLowerCase().startsWith("/me ") || reply.toLowerCase().startsWith("/slap "))) { try { JSONObject o = NetworkConnection.getInstance().say(intent.getIntExtra("cid", -1), intent.getStringExtra("to"), reply, sk); success = o.getBoolean("success"); } catch (Exception e) { e.printStackTrace(); }/* w ww .j av a 2s . c o m*/ } NotificationManagerCompat.from(IRCCloudApplication.getInstance().getApplicationContext()) .cancel(intent.getIntExtra("bid", 0)); if (intent.hasExtra("eids")) { int bid = intent.getIntExtra("bid", -1); long[] eids = intent.getLongArrayExtra("eids"); for (int j = 0; j < eids.length; j++) { if (eids[j] > 0) { Notifications.getInstance().dismiss(bid, eids[j]); } } } if (!success) Notifications.getInstance().alert(intent.getIntExtra("bid", -1), "Sending Failed", reply.startsWith("/") ? "Please launch the IRCCloud app to send this command" : "Your message was not sent. Please try again shortly."); } else { Crashlytics.log(Log.ERROR, "IRCCloud", "RemoteInputService received no remoteinput"); } } } }
From source file:com.github.tony19.timber.loggly.JsonFormatterTest.java
@Test public void formatIgnoresNullThrowable() throws IOException { final Throwable nullThrowable = null; final JsonLog log = getLog(Log.INFO, "tag", "message", nullThrowable); assertThat(log.exception, is(nullValue())); }
From source file:com.github.tony19.timber.loggly.JsonFormatterTest.java
@Test public void formatRendersThrowable() throws IOException { final String error = "my error message"; final JsonLog log = getLog(Log.INFO, "tag", "message", new RuntimeException(error)); assertThat(log.exception, containsString(error)); assertThat(log.exception, containsString("RuntimeException")); }
From source file:com.example.android.common.logger.LogView.java
/** * Formats the log data and prints it out to the LogView. * @param priority Log level of the data being logged. Verbose, Error, etc. * @param tag Tag for for the log data. Can be used to organize log statements. * @param msg The actual message to be logged. The actual message to be logged. * @param tr If an exception was thrown, this can be sent along for the logging facilities * to extract and print useful information. *//*from w w w . j a va 2s. c o m*/ @Override public void println(int priority, String tag, String msg, Throwable tr) { String priorityStr = null; // For the purposes of this View, we want to print the priority as readable text. switch (priority) { case android.util.Log.VERBOSE: priorityStr = "VERBOSE"; break; case android.util.Log.DEBUG: priorityStr = "DEBUG"; break; case android.util.Log.INFO: priorityStr = "INFO"; break; case android.util.Log.WARN: priorityStr = "WARN"; break; case android.util.Log.ERROR: priorityStr = "ERROR"; break; case android.util.Log.ASSERT: priorityStr = "ASSERT"; break; default: break; } // Handily, the Log class has a facility for converting a stack trace into a usable string. String exceptionStr = null; if (tr != null) { exceptionStr = android.util.Log.getStackTraceString(tr); } // Take the priority, tag, message, and exception, and concatenate as necessary // into one usable line of text. final StringBuilder outputBuilder = new StringBuilder(); String delimiter = "\t"; appendIfNotNull(outputBuilder, priorityStr, delimiter); appendIfNotNull(outputBuilder, tag, delimiter); appendIfNotNull(outputBuilder, msg, delimiter); appendIfNotNull(outputBuilder, exceptionStr, delimiter); // In case this was originally called from an AsyncTask or some other off-UI thread, // make sure the update occurs within the UI thread. ((Activity) getContext()).runOnUiThread((new Thread(new Runnable() { @Override public void run() { // Display the text we just generated within the LogView. appendToLog(outputBuilder.toString()); } }))); if (mNext != null) { mNext.println(priority, tag, msg, tr); } }