List of usage examples for android.util Log w
public static int w(String tag, Throwable tr)
From source file:com.achep.acdisplay.notifications.NotificationUtils.java
public static Context createContext(Context context, StatusBarNotification n) { try {/*from w ww . j a v a 2 s . c o m*/ return context.createPackageContext(n.getPackageName(), Context.CONTEXT_RESTRICTED); } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, "Failed to create notification\'s context"); return null; } }
From source file:com.daskiworks.ghwatch.backend.NotificationStreamParser.java
public static NotificationStream parseNotificationStream(JSONArray json) throws InvalidObjectException { NotificationStream ret = new NotificationStream(); try {// ww w. j a v a2 s . c o m for (int i = 0; i < json.length(); i++) { JSONObject notification = json.getJSONObject(i); JSONObject subject = notification.getJSONObject("subject"); JSONObject repository = notification.getJSONObject("repository"); String updatedAtStr = Utils.trimToNull(notification.getString("updated_at")); Date updatedAt = null; try { if (updatedAtStr != null) { if (updatedAtStr.endsWith("Z")) updatedAtStr = updatedAtStr.replace("Z", "GMT"); updatedAt = df.parse(updatedAtStr); } } catch (ParseException e) { Log.w(TAG, "Invalid date format for value: " + updatedAtStr); } ret.addNotification(new Notification(notification.getLong("id"), notification.getString("url"), subject.getString("title"), subject.getString("type"), subject.getString("url"), subject.getString("latest_comment_url"), repository.getString("full_name"), repository.getJSONObject("owner").getString("avatar_url"), updatedAt, notification.getString("reason"))); } } catch (Exception e) { throw new InvalidObjectException("JSON message is invalid: " + e.getMessage()); } return ret; }
From source file:com.kevinquan.android.utils.JSONUtils.java
/** * Returns a "pretty print" string version of the JSONObject * @param obj The object to pretty print * @param indentation The amount of indentation for each level * @return A pretty string /*from w w w .j av a2 s .co m*/ */ public static String prettyPrint(JSONObject obj, int indentation) { if (obj == null) { return new String(); } try { return obj.toString(indentation); } catch (JSONException je) { Log.w(TAG, "Could not pretty print JSON: " + obj.toString()); return new String(); } }
From source file:com.intel.iotkitlib.utils.Utilities.java
public static List<NameValuePair> createBasicHeadersWithBearerToken() { if (sharedPreferences == null) { Log.w(TAG, "cannot find shared preferences object, not able to take bearer token"); return null; }/* w w w.j a v a 2 s. c o m*/ //building header value(need persistent to store to take auth token at run time) String bearerToken = IotKit.HEADER_AUTHORIZATION_BEARER + " " + sharedPreferences.getString("auth_token", ""); return Utilities .addHttpHeaders( Utilities.addHttpHeaders(Utilities.createEmptyListForHeaders(), IotKit.HEADER_CONTENT_TYPE_NAME, IotKit.HEADER_CONTENT_TYPE_JSON), IotKit.HEADER_AUTHORIZATION, bearerToken); }
From source file:net.nordist.lloydproof.CorrectionStorage.java
@Override public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) { Log.w(TAG, "Upgrading database from v" + oldVersion + " to v" + newVersion + ", which will destroy all old data"); database.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME + ";"); onCreate(database);/*from www . j av a2 s . c o m*/ }
From source file:org.alfresco.mobile.android.platform.exception.CloudExceptionUtils.java
public static void handleCloudException(Context context, Long accountId, Exception exception, boolean forceRefresh, String taskId) { Log.w(TAG, Log.getStackTraceString(exception)); if (exception instanceof AlfrescoSessionException) { AlfrescoSessionException ex = ((AlfrescoSessionException) exception); switch (ex.getErrorCode()) { case ErrorCodeRegistry.SESSION_API_KEYS_INVALID: case ErrorCodeRegistry.SESSION_REFRESH_TOKEN_EXPIRED: requestOAuthAuthentication(context, accountId, taskId, forceRefresh); return; default:// w ww . j a v a 2 s .c o m if (ex.getMessage().contains("No authentication challenges found") || ex.getErrorCode() == 100) { requestOAuthAuthentication(context, accountId, taskId, forceRefresh); return; } break; } } if (exception instanceof AlfrescoServiceException) { AlfrescoServiceException ex = ((AlfrescoServiceException) exception); if ((ex.getErrorCode() == 104 || (ex.getMessage() != null && ex.getMessage().contains("No authentication challenges found")))) { requestOAuthAuthentication(context, accountId, taskId, forceRefresh); return; } else { Bundle b = new Bundle(); b.putInt(SimpleAlertDialogFragment.ARGUMENT_ICON, R.drawable.ic_application_logo); b.putInt(SimpleAlertDialogFragment.ARGUMENT_TITLE, R.string.error_general_title); b.putInt(SimpleAlertDialogFragment.ARGUMENT_POSITIVE_BUTTON, android.R.string.ok); b.putInt(SimpleAlertDialogFragment.ARGUMENT_MESSAGE, AlfrescoExceptionHelper.getMessageId(context, exception)); BaseActionUtils.actionDisplayDialog(context, b); return; } } if (exception instanceof CmisConnectionException) { CmisConnectionException ex = ((CmisConnectionException) exception); if (ex.getMessage().contains("No authentication challenges found")) { requestOAuthAuthentication(context, accountId, taskId, forceRefresh); return; } } if (exception instanceof AlfrescoSessionException) { int messageId = R.string.error_session_notfound; AlfrescoSessionException se = ((AlfrescoSessionException) exception); if (se.getErrorCode() == ErrorCodeRegistry.GENERAL_HTTP_RESP && se.getMessage() != null && se.getMessage().contains(HttpStatus.SC_SERVICE_UNAVAILABLE + "")) { messageId = R.string.error_session_cloud_unavailable; } EventBusManager.getInstance().post(new LoadAccountErrorEvent(null, accountId, exception, messageId)); } }
From source file:Main.java
/** * decide use XLOG or android default log * @param tag log tag/*from w w w. j a v a2s. c om*/ * @param msg log info message * @return log level */ public static int w(String tag, String msg) { return /*XLOG_ON ? Xlog.w(tag, msg) : */Log.w(tag, msg); }
From source file:sg.macbuntu.android.pushcontacts.DeviceRegistrar.java
public static void registerWithServer(final Context context, final String deviceRegistrationID) { try {//from w w w . j a v a 2 s . c o m HttpResponse res = makeRequest(context, deviceRegistrationID, REGISTER_URL); if (res.getStatusLine().getStatusCode() == 200) { SharedPreferences settings = Prefs.get(context); SharedPreferences.Editor editor = settings.edit(); editor.putString("deviceRegistrationID", deviceRegistrationID); editor.commit(); } else { Log.w(TAG, "Registration error " + String.valueOf(res.getStatusLine().getStatusCode())); } } catch (PendingAuthException e) { // Ignore - we'll reregister later } catch (Exception e) { Log.w(TAG, "Registration error " + e.getMessage()); } // Update dialog activity context.sendBroadcast(new Intent("sg.macbuntu.android.pushcontacts.UPDATE_UI")); }
From source file:org.springframework.http.converter.json.MappingJackson2HttpMessageConverterTests.java
@Override public void setUp() throws Exception { super.setUp(); this.converter = new MappingJackson2HttpMessageConverter(); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD) { Log.w(TAG, "Jackson 2.4 is not supported on Android 2.2 and older"); }/*from w w w . j a va 2 s . co m*/ }
From source file:Main.java
public static Size getOptimalPreviewSize(Activity currentActivity, List<Size> sizes, double targetRatio) { // Use a very small tolerance because we want an exact match. final double ASPECT_TOLERANCE = 0.001; if (sizes == null) return null; Size optimalSize = null;/*from w w w . j a va 2s . c o m*/ double minDiff = Double.MAX_VALUE; // Because of bugs of overlay and layout, we sometimes will try to // layout the viewfinder in the portrait orientation and thus get the // wrong size of mSurfaceView. When we change the preview size, the // new overlay will be created before the old one closed, which causes // an exception. For now, just get the screen size Display display = currentActivity.getWindowManager().getDefaultDisplay(); int targetHeight = Math.min(display.getHeight(), display.getWidth()); if (targetHeight <= 0) { // We don't know the size of SurfaceView, use screen height targetHeight = display.getHeight(); } // Try to find an size match aspect ratio and size for (Size size : sizes) { double ratio = (double) size.width / size.height; if (Math.abs(ratio - targetRatio) > ASPECT_TOLERANCE) continue; if (Math.abs(size.height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - targetHeight); } } // Cannot find the one match the aspect ratio. This should not happen. // Ignore the requirement. if (optimalSize == null) { Log.w(TAG, "No preview size match the aspect ratio"); minDiff = Double.MAX_VALUE; for (Size size : sizes) { if (Math.abs(size.height - targetHeight) < minDiff) { optimalSize = size; minDiff = Math.abs(size.height - targetHeight); } } } return optimalSize; }