List of usage examples for android.util Log WARN
int WARN
To view the source code for android.util Log WARN.
Click Source Link
From source file:com.trk.aboutme.facebook.internal.FileLruCache.java
public OutputStream openPutStream(final String key, String contentTag) throws IOException { final File buffer = BufferFile.newFile(this.directory); buffer.delete();//from w w w. j a va2 s . c om if (!buffer.createNewFile()) { throw new IOException("Could not create file at " + buffer.getAbsolutePath()); } FileOutputStream file = null; try { file = new FileOutputStream(buffer); } catch (FileNotFoundException e) { Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "Error creating buffer output stream: " + e); throw new IOException(e.getMessage()); } StreamCloseCallback renameToTargetCallback = new StreamCloseCallback() { @Override public void onClose() { renameToTargetAndTrim(key, buffer); } }; CloseCallbackOutputStream cleanup = new CloseCallbackOutputStream(file, renameToTargetCallback); BufferedOutputStream buffered = new BufferedOutputStream(cleanup, Utility.DEFAULT_STREAM_BUFFER_SIZE); boolean success = false; try { // Prefix the stream with the actual key, since there could be collisions JSONObject header = new JSONObject(); header.put(HEADER_CACHEKEY_KEY, key); if (!Utility.isNullOrEmpty(contentTag)) { header.put(HEADER_CACHE_CONTENT_TAG_KEY, contentTag); } StreamHeader.writeHeader(buffered, header); success = true; return buffered; } catch (JSONException e) { // JSON is an implementation detail of the cache, so don't let JSON exceptions out. Logger.log(LoggingBehavior.CACHE, Log.WARN, TAG, "Error creating JSON header for cache file: " + e); throw new IOException(e.getMessage()); } finally { if (!success) { buffered.close(); } } }
From source file:com.android.talkback.labeling.LabelProvider.java
/** * Updates a label in the labels database. * * @param uri The URI matching {code LABELS_ID_CONTENT_URI} that represents * the specific label to update. * @param values The values to use to update the label. * @param selection The WHERE clause for the query. * @param selectionArgs The arguments for the WHERE clause of the query. * @return The number of rows affected./*from ww w .j av a2s . c o m*/ */ @Override public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) { if (uri == null) { LogUtils.log(this, Log.WARN, NULL_URI_FORMAT_STRING); return 0; } if (!UserManagerCompat.isUserUnlocked(getContext())) { return 0; } switch (sUriMatcher.match(uri)) { case LABELS: { initializeDatabaseIfNull(); int result = mDatabase.update(LabelsTable.TABLE_NAME, values, selection, selectionArgs); getContext().getContentResolver().notifyChange(uri, null /* observer */); return result; } case LABELS_ID: { initializeDatabaseIfNull(); final String labelIdString = uri.getLastPathSegment(); final int labelId; try { labelId = Integer.parseInt(labelIdString); } catch (NumberFormatException e) { LogUtils.log(this, Log.WARN, UNKNOWN_URI_FORMAT_STRING, uri); return 0; } final String where = String.format(Locale.ROOT, "%s = %d", LabelsTable.KEY_ID, labelId); final int result = mDatabase.update(LabelsTable.TABLE_NAME, values, combineSelectionAndWhere(selection, where), selectionArgs); getContext().getContentResolver().notifyChange(uri, null /* observer */); return result; } default: LogUtils.log(this, Log.WARN, UNKNOWN_URI_FORMAT_STRING, uri); return 0; } }
From source file:com.irccloud.android.activity.PastebinViewerActivity.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/*w w w. j av a2s . c o m*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setTheme(ColorScheme.getDialogWhenLargeTheme(ColorScheme.getUserTheme())); onMultiWindowModeChanged(isMultiWindow()); if (savedInstanceState == null && (getWindowManager().getDefaultDisplay().getWidth() < TypedValue .applyDimension(TypedValue.COMPLEX_UNIT_DIP, 800, getResources().getDisplayMetrics()) || isMultiWindow())) overridePendingTransition(R.anim.slide_in_right, R.anim.fade_out); setContentView(R.layout.activity_pastebin); mSpinner = findViewById(R.id.spinner); toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); toolbar.setNavigationIcon(android.support.v7.appcompat.R.drawable.abc_ic_ab_back_material); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); } }); getSupportActionBar().setTitle(""); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mWebView = findViewById(R.id.image); mWebView.setBackgroundColor(ColorScheme.getInstance().contentBackgroundColor); mWebView.getSettings().setBuiltInZoomControls(true); if (Integer.parseInt(Build.VERSION.SDK) >= 19) mWebView.getSettings() .setDisplayZoomControls(!getPackageManager().hasSystemFeature("android.hardware.touchscreen")); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.addJavascriptInterface(new JSInterface(), "Android"); mWebView.getSettings().setLoadWithOverviewMode(false); mWebView.getSettings().setUseWideViewPort(false); mWebView.getSettings().setAppCacheEnabled(false); mWebView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { fail(); } @Override public void onLoadResource(WebView view, String url) { } }); mWebView.setWebChromeClient(new WebChromeClient() { @Override public boolean onConsoleMessage(ConsoleMessage consoleMessage) { Crashlytics.log( consoleMessage.messageLevel() == ConsoleMessage.MessageLevel.ERROR ? Log.ERROR : Log.WARN, "IRCCloud", "Javascript error - line: " + consoleMessage.lineNumber() + " message: " + consoleMessage.message()); return super.onConsoleMessage(consoleMessage); } }); if (savedInstanceState != null && savedInstanceState.containsKey("url")) { url = savedInstanceState.getString("url"); html = savedInstanceState.getString("html"); mWebView.loadDataWithBaseURL(url, html, "text/html", "UTF-8", null); } else { if (getIntent() != null && getIntent().getDataString() != null) { url = getIntent().getDataString().replace(getResources().getString(R.string.PASTE_SCHEME), "https"); if (!url.contains("?")) url += "?"; try { url += "&mobile=android&version=" + getPackageManager().getPackageInfo(getPackageName(), 0).versionName + "&theme=" + ColorScheme.getUserTheme(); } catch (PackageManager.NameNotFoundException e) { } new FetchPastebinTask().execute(); Answers.getInstance().logContentView(new ContentViewEvent().putContentType("Pastebin")); } else { finish(); } } }
From source file:biz.bokhorst.xprivacy.Util.java
@SuppressLint("NewApi") public static int getAppId(int uid) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) try {/*from w w w . j av a2 s. c o m*/ // UserHandle: public static final int getAppId(int uid) Method method = (Method) UserHandle.class.getDeclaredMethod("getAppId", int.class); uid = (Integer) method.invoke(null, uid); } catch (Throwable ex) { Util.log(null, Log.WARN, ex.toString()); } return uid; }
From source file:com.ameron32.apps.tapnotes._unused.original.LoginActivity.java
private Bundle getMergedOptions() { // Read activity metadata from AndroidManifest.xml ActivityInfo activityInfo = null;/* www . j a v a 2s .co m*/ try { activityInfo = getPackageManager().getActivityInfo(this.getComponentName(), PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { if (Parse.getLogLevel() <= Parse.LOG_LEVEL_ERROR && Log.isLoggable(LOG_TAG, Log.WARN)) { Log.w(LOG_TAG, e.getMessage()); } } // The options specified in the Intent (from ParseLoginBuilder) will // override any duplicate options specified in the activity metadata Bundle mergedOptions = new Bundle(); if (activityInfo != null && activityInfo.metaData != null) { mergedOptions.putAll(activityInfo.metaData); } if (getIntent().getExtras() != null) { mergedOptions.putAll(getIntent().getExtras()); } return mergedOptions; }
From source file:com.kth.common.utils.etc.LogUtil.java
/** * WARN ?.//from w w w . j a v a 2 s .com * * @param clazz ?? Class. * @param tr Throwable. */ public static void w(final Class<?> clazz, final Throwable tr) { if (LogUtil.isWarnEnabled()) { Log.println(Log.WARN, TAG, LogUtil.getClassLineNumber(clazz) + " - " + Log.getStackTraceString(tr)); // ?? ? ?. if (LogUtil.isFileLogEnabled()) { write(Log.WARN, LogUtil.getClassLineNumber(clazz), tr); } } }
From source file:com.scvngr.levelup.core.util.LogManager.java
/** * Logs a message to the Android log.//from w w w .j a v a 2 s . co m * * @param logLevel {@link Log#VERBOSE}, {@link Log#DEBUG}, {@link Log#INFO}, {@link Log#WARN}, * or {@link Log#ERROR}. * @param message the message to be logged. This message is expected to be a format string if * messageFormatArgs is not null. * @param messageFormatArgs formatting arguments for the message, or null if the string is to be * handled without formatting. * @param err an optional error to log with a stacktrace. */ private static void logMessage(final int logLevel, @NonNull final String message, @Nullable final Object[] messageFormatArgs, @Nullable final Throwable err) { final String preppedMessage = formatMessage(message, messageFormatArgs); final StackTraceElement[] trace = Thread.currentThread().getStackTrace(); final String sourceClass = trace[STACKTRACE_SOURCE_FRAME_INDEX].getClassName(); final String sourceMethod = trace[STACKTRACE_SOURCE_FRAME_INDEX].getMethodName(); final String logcatLogLine = String.format(Locale.US, FORMAT, Thread.currentThread().getName(), sourceClass, sourceMethod, preppedMessage); switch (logLevel) { case Log.VERBOSE: { if (null == err) { Log.v(sLogTag, logcatLogLine); } else { Log.v(sLogTag, logcatLogLine, err); } break; } case Log.DEBUG: { if (null == err) { Log.d(sLogTag, logcatLogLine); } else { Log.d(sLogTag, logcatLogLine, err); } break; } case Log.INFO: { if (null == err) { Log.i(sLogTag, logcatLogLine); } else { Log.i(sLogTag, logcatLogLine, err); } break; } case Log.WARN: { if (null == err) { Log.w(sLogTag, logcatLogLine); } else { Log.w(sLogTag, logcatLogLine, err); } break; } case Log.ERROR: { if (null == err) { Log.e(sLogTag, logcatLogLine); } else { Log.e(sLogTag, logcatLogLine, err); } break; } case Log.ASSERT: { if (null == err) { Log.wtf(sLogTag, logcatLogLine); } else { Log.wtf(sLogTag, logcatLogLine, err); } break; } default: { throw new AssertionError(); } } }
From source file:org.thoughtland.xlocation.Util.java
@SuppressLint("NewApi") public static int getUserId(int uid) { int userId = 0; if (uid > 99) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) try { // TODO: update by method in SDK 20 // UserHandle: public static final int getUserId(int uid) Method method = (Method) UserHandle.class.getDeclaredMethod("getUserId", int.class); userId = (Integer) method.invoke(null, uid); } catch (Throwable ex) { Util.log(null, Log.WARN, ex.toString()); }//w w w . j a va2s .c om } else userId = uid; return userId; }
From source file:com.parse.starter.ParseLoginActivity.java
/** * @see android.app.Activity#isDestroyed() *///from ww w. j a va 2s . c om // @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) // @Override // public boolean isDestroyed() { // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) { // return super.isDestroyed(); // } // return destroyed; // } private Bundle getMergedOptions() { // Read activity metadata from AndroidManifest.xml ActivityInfo activityInfo = null; try { activityInfo = getPackageManager().getActivityInfo(this.getComponentName(), PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { if (Parse.getLogLevel() <= Parse.LOG_LEVEL_ERROR && Log.isLoggable(LOG_TAG, Log.WARN)) { Log.w(LOG_TAG, e.getMessage()); } } // The options specified in the Intent (from ParseLoginBuilder) will // override any duplicate options specified in the activity metadata Bundle mergedOptions = new Bundle(); if (activityInfo != null && activityInfo.metaData != null) { mergedOptions.putAll(activityInfo.metaData); } if (getIntent().getExtras() != null) { mergedOptions.putAll(getIntent().getExtras()); } return mergedOptions; }
From source file:com.radicaldynamic.groupinform.activities.AccountDeviceList.java
public static ArrayList<AccountDevice> loadDeviceList() { if (Collect.Log.DEBUG) Log.d(Collect.LOGTAG, t + "loading device cache"); ArrayList<AccountDevice> devices = new ArrayList<AccountDevice>(); if (!new File(Collect.getInstance().getCacheDir(), FileUtilsExtended.DEVICE_CACHE_FILE).exists()) { if (Collect.Log.WARN) Log.w(Collect.LOGTAG, t + "device cache file cannot be read: aborting loadDeviceList()"); return devices; }//from w ww. j a v a2 s. c o m try { FileInputStream fis = new FileInputStream( new File(Collect.getInstance().getCacheDir(), FileUtilsExtended.DEVICE_CACHE_FILE)); InputStreamReader reader = new InputStreamReader(fis); BufferedReader buffer = new BufferedReader(reader, 8192); StringBuilder sb = new StringBuilder(); String cur; while ((cur = buffer.readLine()) != null) { sb.append(cur + "\n"); } buffer.close(); reader.close(); fis.close(); try { // int assignedSeats = 0; JSONArray jsonDevices = (JSONArray) new JSONTokener(sb.toString()).nextValue(); for (int i = 0; i < jsonDevices.length(); i++) { JSONObject jsonDevice = jsonDevices.getJSONObject(i); AccountDevice device = new AccountDevice(jsonDevice.getString("id"), jsonDevice.getString("rev"), jsonDevice.getString("alias"), jsonDevice.getString("email"), jsonDevice.getString("status")); // Optional information that will only be present if the user is also an account owner device.setLastCheckin(jsonDevice.optString("lastCheckin")); device.setPin(jsonDevice.optString("pin")); device.setRole(jsonDevice.optString("role")); // Update the lookup hash Collect.getInstance().getInformOnlineState().getAccountDevices().put(device.getId(), device); // Show a device so long as it hasn't been marked as removed if (!device.getStatus().equals("removed")) { devices.add(device); // assignedSeats++; } } // // Record the number of seats in this account that are assigned & allocated (not necessarily "active") // Collect.getInstance().getInformOnlineState().setAccountAssignedSeats(assignedSeats); } catch (JSONException e) { // Parse error (malformed result) if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "failed to parse JSON " + sb.toString()); e.printStackTrace(); } } catch (Exception e) { if (Collect.Log.ERROR) Log.e(Collect.LOGTAG, t + "unable to read device cache: " + e.toString()); e.printStackTrace(); } return devices; }