Aprel
Aprel

Reputation: 1179

Android Private API, Invocation failure

I need, for my app, some private APIs and I found this. So I tried to do reflection and invoke the method getDefault as follows:

Class ActivityManagerNative = Class.forName("android.app.ActivityManagerNative");
Class IActivityManager = Class.forName("android.app.IActivityManager");

Method getDefault = ActivityManagerNative.getMethod("getDefault", null);
Object am = IActivityManager.cast(getDefault.invoke(ActivityManagerNative, null));

It worked nicely. Then I made one jar and one apk. I'm just trying to run apk in the terminal with am start and also to run jar with dalvikvm in terminal. The difference between both is that .jar file doesn't work. It loads successfully ActivityManagerNative and getDefault but not the invocation. The Exception is something with getContextObject. What does it mean? Can somebody help me?

Upvotes: 2

Views: 636

Answers (0)

Related Questions