android – 在运行时从另一个应用程序获取customview
我正在努力从另一个应用程序获取CustomView.假设我有两个应用程序A和B.我知道CustomView的包名称,例如com.applicationb.CustomView.是否可以在运行时在应用程序A中创建此类的对象?
我的目标是找到一种方法来创建CustomViews并能够在我的应用程序中显示它们.但我希望他们(视图)是一个单独的apk,可以发布到Android Market,并作为某种扩展名下载.
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
我希望这会奏效.我回头告诉你.