Android反射MediaPlayer的getAudioStreamType()私有方法

Android反射MediaPlayer的getAudioStreamType()私有方法_第1张图片

import android.media.AudioManager;
import android.media.MediaPlayer;
import java.lang.reflect.Method;

try {
     MediaPlayer mPlayer = new MediaPlayer();
     Class clazz = Class.forName("android.media.MediaPlayer");
     Method method = clazz.getDeclaredMethod("getAudioStreamType");//方法名,参数类型(无参)
     method.setAccessible(true);
     int value = (int)method.invoke(mPlayer);
     Log.e("test", " getAudioStreamType ======= " + value);
     } catch (Exception e) {
       e.printStackTrace();
     }

 

你可能感兴趣的:(Android系统调试方法)