List of usage examples for android.util Log w
public static int w(String tag, String msg, Throwable tr)
From source file:Main.java
public static long getLastProgramEndTimeMillis(ContentResolver resolver, Uri channelUri) { Uri uri = TvContract.buildProgramsUriForChannel(channelUri); String[] projection = { Programs.COLUMN_END_TIME_UTC_MILLIS }; Cursor cursor = null;//ww w . j av a 2 s . co m try { // TvProvider returns programs chronological order by default. cursor = resolver.query(uri, projection, null, null, null); if (cursor == null || cursor.getCount() == 0) { return 0; } cursor.moveToLast(); return cursor.getLong(0); } catch (Exception e) { Log.w(TAG, "Unable to get last program end time for " + channelUri, e); } finally { if (cursor != null) { cursor.close(); } } return 0; }
From source file:Main.java
/** * Convenience method for writing a verbose message to the logcat * @param verbose/*from w ww.java2s . co m*/ * @param args */ public static void log(String verbose, Object... args) { try { Method m = Log.class.getMethod("v", new Class<?>[] { String.class, String.class }); log(m, verbose, args); } catch (Exception e) { Log.w("AbLE", "Log Failed", e); } }
From source file:Main.java
private static <T> T newInstance(Context context, Class clazz, Class[] constructorSig, Object... arguments) { try {//from w ww. ja v a 2 s .co m Constructor<?> constructor = clazz.getConstructor(constructorSig); return (T) constructor.newInstance(arguments); } catch (Exception e) { Log.w(LOG_TAG, "Cannot instantiate class: " + clazz.getName(), e); } return null; }
From source file:Main.java
/** * * Get a tcp socket connection to specified IP address and port proxied by adb * * The proxying is transparent, e.g. if a socket is returned, then it can be written to and * read from as if it is directly connected to the target * * @param remoteAddress IP address of the host to connect to * @param remotePort port of the host to connect to * @return a valid Socket instance if successful, null otherwise *///from ww w . j ava2 s.co m public static Socket getForwardedSocket(int remoteAddress, int remotePort) { try { Socket socket = new Socket(ADB_HOST, ADB_PORT); String cmd = "tcp:" + remotePort + ":" + convert(remoteAddress); if (!sendAdbCmd(socket.getInputStream(), socket.getOutputStream(), cmd)) { socket.close(); return null; } return socket; } catch (IOException ioe) { Log.w(LOGTAG, "error creating adb socket", ioe); return null; } }
From source file:de.stadtrallye.rallyesoft.util.JSONConverter.java
@Override public T convert(JSONObject input) { try {//from www .j a v a 2 s . c o m return doConvert(input); } catch (JSONException e) { Log.w("JSONConverter", "falling back, conversion failed", e); return fallback(); } }
From source file:com.google.cast.samples.games.spellcast.messages.PlayerPlayingMessage.java
@Override public JSONObject toJSON() { JSONObject serialized = new JSONObject(); try {/*from w w w . ja va2 s . co m*/ serialized.put(KEY_DIFFICULTY_SETTING, SpellCastMessage.spellCastEnumToInt(mDifficulty)); } catch (JSONException e) { Log.w(TAG, "JSONException converting spell list to JSON.", e); } return serialized; }
From source file:com.google.cast.samples.games.spellcast.messages.SpellCastGameData.java
public SpellCastGameData(JSONObject gameData) { if (gameData != null) { try {//from w w w . j a v a 2s . com int receiverStateId = gameData.getInt(KEY_GAME_STATE_ID); mCurrentGameState = getGameStateFromId(receiverStateId); } catch (JSONException e) { Log.w(TAG, "JSONException parsing gameData", e); } } }
From source file:crow.util.JsonUtil.java
private static JSONObject toJSONObject(Map<String, Object> map) throws JSONException { JSONObject jsonOb = new JSONObject(); if ((map == null) || (map.isEmpty())) return jsonOb; Iterator<String> iter = map.keySet().iterator(); while (iter.hasNext()) { String key = iter.next(); Object value = map.get(key); if ((value instanceof String) || (value instanceof Integer) || (value instanceof Double) || (value instanceof Long) || (value instanceof Float)) { jsonOb.put(key, value);// ww w . j a v a 2 s . com continue; } if ((value instanceof Map<?, ?>)) { try { @SuppressWarnings("unchecked") Map<String, Object> valueMap = (Map<String, Object>) value; jsonOb.put(key, toJSONObject(valueMap)); } catch (ClassCastException e) { Log.w(TAG, "Unknown map type in json serialization: ", e); } continue; } if ((value instanceof Set<?>)) { try { @SuppressWarnings("unchecked") Set<Object> valueSet = (Set<Object>) value; jsonOb.put(key, toJSONObject(valueSet)); } catch (ClassCastException e) { Log.w(TAG, "Unknown map type in json serialization: ", e); } continue; } Log.e(TAG, "Unknown value in json serialization: " + value.toString() + " : " + value.getClass().getCanonicalName().toString()); } return jsonOb; }
From source file:com.google.cast.samples.games.spellcast.messages.PlayerReadyMessage.java
@Override public JSONObject toJSON() { JSONObject serialized = new JSONObject(); try {/*w w w . ja v a 2 s . c o m*/ serialized.put(KEY_PLAYER_NAME, mPlayerName); serialized.put(KEY_AVATAR_INDEX, mAvatarIndex); } catch (JSONException e) { Log.w(TAG, "JSONException converting spell list to JSON.", e); } return serialized; }
From source file:com.google.cast.samples.games.spellcast.messages.PlayerRoundInfoMessage.java
public PlayerRoundInfoMessage(JSONObject message) { try {// w w w . j a v a 2 s .c o m mCastSpellsDurationMillis = message.getInt(KEY_CAST_SPELLS_DURATION); int playerBonusInt = message.getInt(KEY_PLAYER_BONUS); mPlayerBonus = getPlayerBonusFromInt(playerBonusInt); } catch (JSONException e) { Log.w(TAG, "JSONException parsing gameData: " + message, e); } }