1
내 도구에서 반사 방법을 사용하여 의 밝기를 변경하려고 시도했지만 이 코드가 순간에 실패했습니다. setBacklightBrightness.invoke (power, new Object [] {Brightness}); 및 쓰기 호출 오류. 도와주세요!안드로이드에서 작동하지 않는 이유 setBacklightBrightness (int)
public static void LoadIPowerClass(Context context)
{
try{
//Load classes and objects
Object power;
Context fContext = context;
Class <?> ServiceManager = Class.forName("android.os.ServiceManager");
Class <?> Stub = Class.forName("android.os.IPowerManager$Stub");
Method getService = ServiceManager.getMethod("getService", new Class[] {String.class});
//Method asInterface = GetStub.getMethod("asInterface", new Class[] {IBinder.class});//of this class?
Method asInterface = Stub.getMethod("asInterface", new Class[] {IBinder.class}); //of this class?
IBinder iBinder = (IBinder) getService.invoke(null, new Object[] {Context.POWER_SERVICE});//
power = asInterface.invoke(null,iBinder);//or call constructor Stub?//
Method setBacklightBrightness = power.getClass().getMethod("setBacklightBrightness", new Class[]{int.class});
int Brightness = 5;
setBacklightBrightness.invoke(power, new Object[]{Brightness});//HERE Failen
Log.i(TAG, "Load internal IPower classes Ok");
}catch(InvocationTargetException e){ //HERE catch!!!!
....