我正在编写一个应用程序,用于列出系统上安装的应用程序 我正在使用PackageManager和queryIntentActivities()来获取应用程序列表.
我可以启动它,卸载它(使用ACTION_DELETE),但我不知道如何显示细节(用户可以强制停止,移动到/从SD卡移动,看磁盘空间使用等)?
我尝试了ACTION_VIEW,但它也显示2.1上的卸载对话框(还没有检查其他版本).除了android-dev邮件列表中一个未解答的问题,我也没有找到任何东西.
Intent intent;
if (android.os.Build.VERSION.SDK_INT >= 9) {
/* on 2.3 and newer, use APPLICATION_DETAILS_SETTINGS with proper URI */
Uri packageURI = Uri.parse("package:" + pkgName);
intent = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS", packageURI);
ctx.startActivity(intent);
} else {
/* on older Androids, use trick to show app details */
intent = new Intent(Intent.ACTION_VIEW);
intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails");
intent.putExtra("com.android.settings.ApplicationPkgName", pkgName);
intent.putExtra("pkg", pkgName);
ctx.startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)
从 API Level 9(又名 Android 2.3)开始,您应该能够使用ACTION_APPLICATION_DETAILS_SETTINGS它。在以前的 Android 版本中无法进入此屏幕。
| 归档时间: |
|
| 查看次数: |
4717 次 |
| 最近记录: |