如何从 Android 中的另一个应用程序启动 Activity [英] How to launch an Activity from another Application in Android

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

问题描述

我想从我的 Android 应用程序启动一个已安装的包.我认为可以使用意图,但我没有找到这样做的方法.有没有链接,在哪里可以找到信息?

I want to launch an installed package from my Android application. I assume that it is possible using intents, but I didn't find a way of doing it. Is there a link, where to find the information?

推荐答案

如果您不知道主要活动,那么可以使用包名来启动应用程序.

If you don't know the main activity, then the package name can be used to launch the application.

Intent launchIntent = getPackageManager().getLaunchIntentForPackage("com.package.address");
if (launchIntent != null) { 
    startActivity(launchIntent);//null pointer check in case package name was not found
}

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

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