调用Android系统“应用程序信息(Application Info)”界面
来源:互联网 发布:手机记录仪软件 编辑:程序博客网 时间:2024/05/23 00:01
正好用到这个功能,同学推荐了这篇,真是感谢哦!
“Android系统设置->应用程序->管理应用程序”列表下,列出了系统已安装的应用程序。选择其中一个程序,则进入“应用程序信 息(Application Info)”界面。这个界面显示了程序名称、版本、存储、权限等信息,并有卸载、停止、清除缓存等按钮,可谓功能不少。如果在编写相关程序时(比如任务管 理器)可以调用这个面板,自然提供了很大的方便。那么如何实现呢?
在最新的Android SDK 2.3(API Level 9)中,提供了这样的接口。在文档路径
docs/reference/android/provider/Settings.html#ACTION_APPLICATION_DETAILS_SETTINGS
下,有这样的描述:
public static final String ACTION_APPLICATION_DETAILS_SETTINGS Since: API Level 9
Activity Action: Show screen of details about a particular application.
In some cases, a matching Activity may not exist, so ensure you safeguard against this.
Input: The Intent's data URI specifies the application package name to be shown, with the "package" scheme. That is "package:com.my.app".
Output: Nothing.
Constant Value: "android.settings.APPLICATION_DETAILS_SETTINGS"
就是说,我们只要以android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS作为Action;“package:应用程序的包名”作为URI,就可以用startActivity启动应用程序信息界面了。代码如下:
- Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
- Uri uri = Uri.fromParts(SCHEME, packageName, null);
- intent.setData(uri);
- startActivity(intent);
- // utility method used to start sub activity
- private void startApplicationDetailsActivity() {
- // Create intent to start new activity
- Intent intent = new Intent(Intent.ACTION_VIEW);
- intent.setClass(this, InstalledAppDetails.class);
- intent.putExtra(APP_PKG_NAME, mCurrentPkgName);
- // start new activity to display extended information
- startActivityForResult(intent, INSTALLED_APP_DETAILS);
- }
- Intent i = new Intent(Intent.ACTION_VIEW);
- i.setClassName("com.android.settings","com.android.settings.InstalledAppDetails");
- i.putExtra("com.android.settings.ApplicationPkgName", packageName);
- startActivity(i);
- private static final String SCHEME = "package";
- /**
- * 调用系统InstalledAppDetails界面所需的Extra名称(用于Android 2.1及之前版本)
- */
- private static final String APP_PKG_NAME_21 = "com.android.settings.ApplicationPkgName";
- /**
- * 调用系统InstalledAppDetails界面所需的Extra名称(用于Android 2.2)
- */
- private static final String APP_PKG_NAME_22 = "pkg";
- /**
- * InstalledAppDetails所在包名
- */
- private static final String APP_DETAILS_PACKAGE_NAME = "com.android.settings";
- /**
- * InstalledAppDetails类名
- */
- private static final String APP_DETAILS_CLASS_NAME = "com.android.settings.InstalledAppDetails";
- /**
- * 调用系统InstalledAppDetails界面显示已安装应用程序的详细信息。 对于Android 2.3(Api Level
- * 9)以上,使用SDK提供的接口; 2.3以下,使用非公开的接口(查看InstalledAppDetails源码)。
- *
- * @param context
- *
- * @param packageName
- * 应用程序的包名
- */
- public static void showInstalledAppDetails(Context context, String packageName) {
- Intent intent = new Intent();
- final int apiLevel = Build.VERSION.SDK_INT;
- if (apiLevel >= 9) { // 2.3(ApiLevel 9)以上,使用SDK提供的接口
- intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
- Uri uri = Uri.fromParts(SCHEME, packageName, null);
- intent.setData(uri);
- } else { // 2.3以下,使用非公开的接口(查看InstalledAppDetails源码)
- // 2.2和2.1中,InstalledAppDetails使用的APP_PKG_NAME不同。
- final String appPkgName = (apiLevel == 8 ? APP_PKG_NAME_22
- : APP_PKG_NAME_21);
- intent.setAction(Intent.ACTION_VIEW);
- intent.setClassName(APP_DETAILS_PACKAGE_NAME,
- APP_DETAILS_CLASS_NAME);
- intent.putExtra(appPkgName, packageName);
- }
- context.startActivity(intent);
- }
- 调用Android系统“应用程序信息(Application Info)”界面
- 调用Android系统“应用程序信息(Application Info)”界面
- 调用Android系统“应用程序信息(Application Info)”界面
- 调用Android系统“应用程序信息(Application Info)”界面
- 调用Android系统“应用程序信息(Application Info)”界面
- 调用Android系统“应用程序信息(Application Info)”界面
- 调用Android系统“应用程序信息(Application Info)”界面
- 调用Android系统“应用程序信息(Application Info)”界面
- 调用Android系统“应用程序信息(Application Info)”界面
- 调用Android系统“应用程序信息(Application Info)”界面
- 调用Android系统“应用程序信息(Application Info)”界面
- 调用ANDROID系统“应用程序信息(APPLICATION INFO)”界面
- 调用Android系统“应用程序信息(Application Info)”界面
- Android开发--在应用中调用系统的“应用程序信息(Application Info)”界面
- 打开应用程序信息(Application Info)
- Android 调用系统默认的应用程序列表界面
- android 调用系统方法获取应用程序信息 如缓存大小
- Android Application Info
- js中弹出新窗口并提交需要在新窗口中显示的数据
- WP7 多媒体控件
- android 网络下载的I/0 流细节注意
- NSdata与NSString,Byte数组,UIImage的相互转换
- jQuery实现页面滚动时层智能浮动定位
- 调用Android系统“应用程序信息(Application Info)”界面
- oracle中实现continue,break
- 突然的想法
- 求最大公约数(GCD)
- usb 转串口 链接板子
- object-C 判断字符串是否含有特殊字符
- Oracle复制某一个字段 批量修改(我们可以在插入的时候修改)
- java面试题及答案
- Mysql 存储过程,触发器,视图 学习记录