리플렉션을 사용하여 Android 기기의 라디오 버전을로드하려고합니다. 내 SDK는 API (7)에 다시 지원하지만 Build.RADIO이 API 8에 첨가하고, Build.getRadioVersion은() API에 추가 된 때문에이 작업을 수행해야 14NoSuchMethodException로드 리플렉션을 사용하여 Build.getRadioVersion()
// This line executes fine, but is deprecated in API 14
String radioVersion = Build.RADIO;
// This line executes fine, but is deprecated in API 14
String radioVersion = (String) Build.class.getField("RADIO").get(null);
// This line executes fine.
String radioVersion = Build.getRadioVersion();
// This line throws a MethodNotFoundException.
Method method = Build.class.getMethod("getRadioVersion", String.class);
// The rest of the attempt to call getRadioVersion().
String radioVersion = method.invoke(null).toString();
아마 뭔가 잘못하고 있어요 이리. 어떤 아이디어?
실수로 String 유형 매개 변수를 지정했습니다. 도와 주셔서 감사합니다. –