Android私有API,调用失败
我的应用程序需要一些私有 API,我发现 这个。所以我尝试进行反射并调用 getDefault 方法,如下所示:
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));
它工作得很好。然后我做了一个jar和一个apk。我只是尝试在终端中使用 am start 运行 apk,并在终端中使用 dalvikvm 运行 jar。两者之间的区别在于 .jar 文件不起作用。它成功加载 ActivityManagerNative
和 getDefault,但未加载调用。异常是 getContextObject
的异常。这是什么意思?有人可以帮助我吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论