List of usage examples for java.lang IllegalArgumentException printStackTrace
public void printStackTrace()
From source file:Main.java
public static void setBackIcon(ActionBar actionbar, Drawable backIcon) { try {//from ww w. ja v a 2s . c o m Method method = Class.forName("android.app.ActionBar").getMethod("setBackButtonDrawable", new Class[] { Drawable.class }); try { method.invoke(actionbar, backIcon); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (Resources.NotFoundException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } }
From source file:Main.java
/** * Set the fields' value.// w ww. j a v a 2 s . c om * * @param bean * @param valMap */ public static void setFieldValues(Object bean, Map<String, Object> valMap) { Class<?> cls = bean.getClass(); //Get all fields. Field[] fields = cls.getDeclaredFields(); for (Field field : fields) { if (valMap.containsKey(field.getName())) { field.setAccessible(true); try { field.set(bean, valMap.get(field.getName())); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } } }
From source file:Main.java
/** * Get the value of the data column for this Uri. This is useful for * MediaStore Uris, and other file-based ContentProviders. * * @param context The context.//from w w w . j a v a 2s . c o m * @param uri The Uri to query. * @param selection (Optional) Filter used in the query. * @param selectionArgs (Optional) Selection arguments used in the query. * @return The value of the _data column, which is typically a file path. */ private static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) { Cursor cursor = null; final String column = MediaStore.Images.Media.DATA; final String[] projection = { column }; try { cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null); if (cursor != null && cursor.moveToFirst()) { final int column_index = cursor.getColumnIndexOrThrow(column); return cursor.getString(column_index); } } catch (IllegalArgumentException e) { e.printStackTrace(); } finally { if (cursor != null) { cursor.close(); } } return null; }
From source file:Main.java
/** * Convert the current time in milliseconds to readable string as given format. * Notice: The time is counted since January 1, 1970 00:00:00.0 UTC. * @param format//from w w w .j ava2 s. c om * y year * M month in the year * d day * h hours(12) * H hours(24) * m minute * s second * S millisecond * E weekday * D days in the year */ public static String convertMillisTime(long time_millis, String format) { if (time_millis <= 0) { return ""; } String result = ""; try { SimpleDateFormat dateFormat = new SimpleDateFormat(format, Locale.US); result = dateFormat.format(new Date(time_millis)); } catch (IllegalArgumentException e) { e.printStackTrace(); } return result; }
From source file:Main.java
/** * Get all fields' value and put them to a map. * /*from ww w . j a v a2 s. co m*/ * @param bean * @return Map */ public static Map<String, Object> getFieldValueMap(Object bean) { Class<?> cls = bean.getClass(); Map<String, Object> valueMap = new HashMap<String, Object>(); // Get all fields. Field[] fields = cls.getDeclaredFields(); for (Field field : fields) { try { field.setAccessible(true); Object value = field.get(bean); // if(value == null) { // valueMap.put(field.getName(), ""); // continue; // } valueMap.put(field.getName(), value); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } return valueMap; }
From source file:Main.java
/** Deactivates GPS. Stops listening for location updates. */ public static void deactivateGps() { try {/*from www .java2 s .c o m*/ if (mLocationListener != null) { mLocationManager.removeUpdates(mLocationListener); mLocationListener = null; } } catch (IllegalArgumentException e) { // ERROR: Intent is null. e.printStackTrace(); } }
From source file:Main.java
public final static int getIntValue(Object owner, String name, int defvalue) { int result = defvalue; setClass(owner.getClass().getName()); Field field = getField(name); if (field != null) { try {/*from w ww.j av a 2 s . co m*/ result = field.getInt(owner); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } } return result; }
From source file:Main.java
public static void playSound(String filePath, MediaPlayer.OnCompletionListener listener) { if (sMediaPlayer == null) { sMediaPlayer = new MediaPlayer(); sMediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override/*from w w w .j a v a2s .c o m*/ public boolean onError(MediaPlayer mediaPlayer, int what, int extra) { sMediaPlayer.reset(); return false; } }); } else { sMediaPlayer.reset(); } try { sMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); if (listener != null) { sMediaPlayer.setOnCompletionListener(listener); } sMediaPlayer.setDataSource(filePath); sMediaPlayer.prepare(); sMediaPlayer.start(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void playSound(String filePath, MediaPlayer.OnCompletionListener onCompletionListener) { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); mMediaPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() { @Override//w w w .j a va 2 s. co m public boolean onError(MediaPlayer mp, int what, int extra) { mMediaPlayer.reset(); return false; } }); } else { mMediaPlayer.reset(); } try { mMediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); if (onCompletionListener != null) { mMediaPlayer.setOnCompletionListener(onCompletionListener); } mMediaPlayer.setDataSource(filePath); mMediaPlayer.prepare(); mMediaPlayer.start(); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (SecurityException e) { e.printStackTrace(); } catch (IllegalStateException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
From source file:Main.java
public static void inject(PathClassLoader pathClassLoader, DexClassLoader loader) { try {//w w w.j av a 2 s.c o m Object dexElements = combineArray(getDexElements(getPathList(pathClassLoader)), getDexElements(getPathList(loader))); Object pathList = getPathList(pathClassLoader); setField(pathList, pathList.getClass(), "dexElements", dexElements); } catch (IllegalArgumentException e) { e.printStackTrace(); } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } }