Android的 - 开始从ApplicationInfo实例的应用 [英] Android - Starting an application from an ApplicationInfo instance

查看:165
本文介绍了Android的 - 开始从ApplicationInfo实例的应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个特定的应用程序的ApplicationInfo实例,我怎么能做出一个Intent来启动应用程序?

我试过

 意向意图=新意图(ApplicationInfoInstance.packageName);

但它给出了一个例外。安装该应用程序如此异常是不是因为这一点。

我想我需要使用

  setClassName(字符串的packageName,弦乐的className);

有人能告诉我获得这两个值?
因为大多数我的应用程序的回报 NULL ApplicationInfoInstance.className;

感谢您。


解决方案

  

如果我有一个特定的应用程序的ApplicationInfo实例,我怎么能做出一个Intent来启动应用程序?


有是在Android的启动程序没有这样的事。一个应用程序可能是零,这是在发射,旨在推出一个或几个活动。

您应该能够使用 getLaunchIntentForPackage()的<一个href=\"http://developer.android.com/reference/android/content/pm/PackageManager.html\"><$c$c>PackageManager得到一个意图满足您的需求(或空,如果没有这样的意图)。

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

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;

Thank you.

解决方案

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

There is no such thing as "launch the app" in Android. An "app" may have zero, one, or several activities that are in the launcher and are designed to be launched.

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).

这篇关于Android的 - 开始从ApplicationInfo实例的应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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