如何调用从另一个机器人应用的一个Android应用 [英] How to call one android application from another android application

查看:160
本文介绍了如何调用从另一个机器人应用的一个Android应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从另一个应用程序调用一款使用Android操作系统的应用程序

I want to call one android application from another application

我已经尝试了一些<一href="http://www.anddev.org/install-run_applications_from_within_another_application-t6909.html">examples,但他们没有工作对我来说,我得到一个包解析错误。

I have tried some examples, but they are not working for me, I'm getting a Package parse error.

假设有两个应用:应用1和应用2

Consider there are two applications: Application1 and Application2

我想从应用程序1调用应用2

I want to call Application2 from Application1

下面是一些示例code要做到这一点:

Here is the some sample code to do this:

Intent i = new Intent();
i.setAction(android.content.Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(fileName),"application/vnd.android.package-archive"); 
startActivity(i);

下面文件名=文件://data/data/package_name/files/Application1.apk;

推荐答案

我觉得这$​​ C $ C可以帮助:

I think this code will help:

Intent intent = new Intent(Intent.ACTION_RUN);
intent.setComponent(new ComponentName("<packet name>", "<class name>"));
List list = packageManager.queryIntentActivities(intent, packageManager.COMPONENT_ENABLED_STATE_DEFAULT);

if(list.size() > 0)
{
 Log.i("Log", "Have application" + list.size());
 startActivity(intent);
}
else
{
    Log.i("Log", "None application");
}

这篇关于如何调用从另一个机器人应用的一个Android应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆