Android - 从 ApplicationInfo 实例启动应用程序

标签 android android-intent

如果我有一个特定应用程序的 ApplicationInfo 实例,我该如何创建启动该应用程序的 Intent?

我试过了

Intent intent = new Intent(ApplicationInfoInstance.packageName);

但它给出了一个异常(exception)。该应用程序已安装,所以异常不是因为那个。

我觉得我需要用

setClassName (String packageName, String className);

有人可以指导我获取这两个值吗? 因为我的大多数应用程序都为 ApplicationInfoInstance.className;

返回 NULL

谢谢。

最佳答案

If I have an ApplicationInfo instance of a particular app, how can I make an Intent to launch the app?

Android 中没有“启动应用程序”这样的东西。一个“应用程序”可能有零个、一个或多个启动器中的 Activity,这些 Activity 旨在启动。

您应该能够在 PackageManager 上使用 getLaunchIntentForPackage()获得满足您需求的 Intent(如果没有这样的 Intent,则返回 null)。

关于Android - 从 ApplicationInfo 实例启动应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4530639/

相关文章:

android - YouTube Intent 在浏览器android中启动

android eclipse 模拟器设备没有运行

android - 如何将按钮从一个位置翻译到另一个位置android

android - ViewPager onPageSelected 从未调用过

android - SwarmConnect Facebook 登录

java - 在android中使用默认应用程序打开文件

java - OnClick 动态添加一个新行到 TableLayout 并从数据库中获取值将其显示在添加的行中并给出总计

java - 带有外部相机应用程序的android相机 Intent ,返回原始 Activity ?

java - ListView Activity 在微调器类内的开关盒中无法正常工作

android - 使用 Intent 将数据从 Activity 传递到 Service