我正在思考如何从另一个应用程序中获取CustomView
的想法。 假设我有两个应用程序A和B。 我知道CustomView
的包名称,例如com.applicationb.CustomView
。 是否可能在运行时在应用程序A中创建此类的对象?
我的目标是找到一种方法来创建CustomViews
并能够在我的应用程序中显示它们。 但我希望它们(视图)成为单独的apk,可以发布到Android市场,并作为某种扩展程序进行下载。
CustomView
只会在屏幕上显示某种动画(例如落叶)。 它不会处理第一个应用程序中的任何数据。
编辑
我发现了这样的内容:
@SuppressWarnings("rawtypes")
Class c = Class.forName(package_name);
Method m = c.getDeclaredMethod(method_name);
m.setAccessible(true);
Canvas can= (Canvas) m.invoke(null, null); // since there are no parameters, and called function is static
我希望这会有效。我会让你知道。