【发布时间】:2010-07-07 17:45:01
【问题描述】:
Android 在基础操作系统和包中提供了很多 Intent。如何确定要发送到 Intent 的参数(即 Data、Extras 等)?例如,您可以使用此意图打开设置应用程序以显示特定应用程序的应用程序信息:
String pkgname = "com.example.application"; // whatever the app is
Intent it = new Intent(Intent.ACTION_VIEW);
it.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
it.putExtra("com.android.settings.ApplicationPkgName", pkgname);
it.putExtra("pkg", pkgname);
问题是我只知道那些Extras 是对的,因为我从别人的源头窃取了它们。我怎么会自己发现呢?
即使查看源代码,我也可以看到要使用的 ClassName,因为它在 AndroidManifext.xml 中作为一个动作,但我没有看到任何指向“pkg”的东西,这显然是合适的 @987654323 @ 与 Froyo 一起使用,对于以前的版本更长。
【问题讨论】:
-
因为你的问题
How could I have found that out by myself?,我投了赞成票。我对使用 Intents 有同样的疑问。