取得系统支持的所有音频格式

try {
//			Method method = Class.forName("android.media.DecoderCapabilities").getDeclaredMethod("getAudioDecoders", new Class[0]);
//			List<?> list = (List<?>) method.invoke(null, null);
//			for(Object obj: list){
//				KuwoLog.v(TAG, obj + "");
//			}
        	
			Field f = Class.forName("android.media.MediaFile").getDeclaredField("sFileTypeMap");
			f.setAccessible(true);
			Object obj = f.get(null);
			HashMap<String, Object> typeMap = (HashMap<String, Object>) obj;
			Iterator<String> keyIterator = typeMap.keySet().iterator();
			while(keyIterator.hasNext()){
				KuwoLog.v(TAG, keyIterator.next());
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		} catch (SecurityException e) {
			e.printStackTrace();
		} 
//		catch (NoSuchMethodException e) {
//			e.printStackTrace();
//		} 
		catch (IllegalArgumentException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} 
//		catch (InvocationTargetException e) {
//			e.printStackTrace();
//		}
		catch (NoSuchFieldException e) {
			e.printStackTrace();
		}
 

你可能感兴趣的:(系统)