Reflected メソッドを使用してウィジェットから明るさを変更しようとしていますが、このコードは setBacklightBrightness.invoke(power, new Object[]{Brightness}); の瞬間に失敗します。呼び出しエラーを書き込みます。助けてください!
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!!!!
....