Mixare有一个应用程序(开源),可让您使用相机查看POI。它使您可以从应用程序中调用应用程序,这要归功于:
Intent i = new Intent();
i.setAction(Intent.ACTION_VIEW);
i.setDataAndType(Uri.parse("http://ws.geonames.org/findNearbyWikipediaJSON"), "application/mixare-json");
startActivity(i);
问题是除了我的应用程序之外,用户必须安装应用程序,所以我所做的是我在我的应用程序中导入了整个应用程序及其所有资源和内容。
但我不知道如何调用主要活动MainActivity.java
,该活动位于包org.mixare
中。
我怎样才能打算调用此活动?我如何在清单中声明它?
答案 0 :(得分:2)
如果您已将应用程序的代码和资源添加到您自己的应用程序中,那么您应该声明并调用它的活动,因为它们是您自己的活动。
Intent i = new Intent(this, MainActivity.class);
startActivity(i);
这就是说,这不是一项微不足道的任务。您需要合并AndroidManifest,如果您不知道自己在做什么,可能会遇到麻烦。例如,除了你的用户之外,用户可以拥有Mixare应用程序,意图可以有相同的操作等。
还有另一种选择。您可以检查是否已安装Mixare应用程序,如果没有,则要求用户执行此操作。根据您的使用情况,这可能是更多“安卓方式”。
答案 1 :(得分:1)
看看, http://code.google.com/p/mixare/wiki/DisplayYourOwnData了解如何通过Intent开始混合。
或者,您可以将mixare用作库项目,然后直接从应用程序调用其MainActivity类Using an Android library project Activity within another project。
这里引用相同的内容 -
在清单文件中声明库组件
在应用程序项目的清单文件中,您必须添加 应用程序将使用的所有组件的声明 从库项目导入。例如,您必须声明任何 ,,,等等,以及 ,和类似的元素。
声明应该通过它们来引用库组件 完全合格的包名称。
然后你绝对可以打电话,
Intent intent = new Intent(this, MainActivity.class);
startActivity(intent);
答案 2 :(得分:1)
不,很难做2 + 2 = 4种类型的清单文件等。
我看到有两种方法可以解决这个问题:
使用外部应用:检查用户是否拥有您希望他拥有的外部应用。否则,将他引导到正确的链接。您可以获取公开应用程序的包名称并在此函数中使用它:
private boolean appInstalledOrNot(String uri) {
PackageManager pm = getPackageManager();
boolean app_installed = false;
try {
pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
app_installed = true;
}
catch (PackageManager.NameNotFoundException e) {
app_installed = false;
}
return app_installed ;
}
组合代码:这没有直接/正确的答案。您需要研究代码并与现有代码集成。
答案 3 :(得分:0)
//appPackageName,appClassName can be found in Logcat
ComponentName component = new ComponentName("appPackageName","appClassName");
Intent intent = new Intent();
intent.setComponent(component);
startActivity(intent);