English 中文(简体)
1. 从另一处操作时间申请中调取习俗
原标题:Getting customview from another application at runtime

我正在努力从另一个申请中获取<代码>CustomView。 请允许我说,我有两个申请A和B。 我知道<条码>的包装名称,例如<条码>。 能否在申请A时设定这一类别的目标?

我的目的是找到一种办法,以建立<条码>,并能够在我的申请中显示。 但是,我想他们(观点)是一个单独的跳板,可以向安伯市场公布,并作为某种延伸下载。

<代码>CustomView只会在屏幕上显示某种估计(例如左下)。 它将不首先处理任何数据。

Edit

I found something like this:

@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

我希望这将发挥作用。 让我知道。

最佳回答

由于我在此表示反对。

String packageName = "com.exapmle.sth";
String className = "com.exapmle.sth.CustomView";

String apkName = getPackageManager().getApplicationInfo(
    packageName, 0).sourceDir;
PathClassLoader myClassLoader = new dalvik.system.PathClassLoader(
    apkName, ClassLoader.getSystemClassLoader());
Class<?> handler = Class.forName(className, true, myClassLoader);
Constructor[] m = handler.getConstructors();
for (int i = 0; i < m.length; i++) {
    if (m[i].getName().contains("CustomView")) {
        animation = (View)m[i].newInstance(new Object[] { this });
        rootRL.addView(animation, new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.FILL_PARENT,
            RelativeLayout.LayoutParams.FILL_PARENT));
    }
}

有了该法典,可以从申请B中从申请A中找到观点。

问题回答

暂无回答




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签