简体   繁体   English

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

[英]Android - Starting an application from an ApplicationInfo instance

If I have an ApplicationInfo instance of a particular app, how can I make an Intent to launch the app? 如果我有特定应用程序的ApplicationInfo实例,我如何制作一个Intent来启动应用程序?

I tried 我试过了

Intent intent = new Intent(ApplicationInfoInstance.packageName);

but it gives an exception. 但它给了一个例外。 The app is installed so the exception is not due to that. 安装该应用程序,因此异常不是由于此。

I think I need to use 我想我需要用

setClassName (String packageName, String className);

Could someone direct me to obtain these two values? 有人可以指导我获得这两个值吗? Because most of my apps returns NULL for ApplicationInfoInstance.className; 因为我的大多数应用程序都为ApplicationInfoInstance.className;返回NULL ApplicationInfoInstance.className;

Thank you. 谢谢。

If I have an ApplicationInfo instance of a particular app, how can I make an Intent to launch the app? 如果我有特定应用程序的ApplicationInfo实例,我如何制作一个Intent来启动应用程序?

There is no such thing as "launch the app" in Android. 在Android中没有“启动应用程序”这样的东西。 An "app" may have zero, one, or several activities that are in the launcher and are designed to be launched. “app”可以具有启动器中的零个,一个或多个活动,并且旨在启动。

You should be able to use getLaunchIntentForPackage() on PackageManager to get an Intent that meets your needs (or null if there is no such Intent ). 您应该能够在PackageManager上使用getLaunchIntentForPackage()来获取满足您需求的Intent (如果没有这样的Intent ,则为null)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM