如何从Android中的另一个应用程序启动应用程序?

时间:2011-06-20 07:30:58

标签: android

  

可能重复:
  Starting One Android App from Another App

我们正在开发一个Android应用程序,比如说com.example.helloone和另一个Android应用程序com.test.hellocalled。这里有两个不同的包,我想从com.test.hellocalled调用com.example.helloone应用程序。你能建议一下吗?

3 个答案:

答案 0 :(得分:4)

在您的活动中,您可以使用

if(isAppInstalled("com.other.package"))
{
    Intent nextIntent = new Intent(Intent.ACTION_MAIN);
    nextIntent.setComponent(new ComponentName("com.other.package","com.other.package.Activity"));
    startActivity(nextIntent);
}

答案 1 :(得分:1)

我不确定如何将某些内容标记为重复,但快速谷歌搜索会显示this question与您的相同。

答案 2 :(得分:0)

您可以使用类似于您希望启动的应用程序的Intent启动活动,也可以使用其文件路径启动应用程序,如下所示:

Intent intent=new Intent();
 intent.setAction(android.content.Intent.ACTION_VIEW);
 intent.setDataAndType(Uri.parse("file:///sdcard/the full path to your file"), "application/vnd.android.package-archive");          "application/vnd.android.package-archive");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

context.startActivity(意向);

相关问题