Android Package Installer

时间:2015-12-24 12:02:27

标签: android packageinstaller

单击apk文件,使用取消按钮和安装按钮启动android默认安装程序活动。我想检查用户点击安装按钮或取消按钮。请指导我谢谢

1 个答案:

答案 0 :(得分:0)

您可以使用此代码在 com.demo.example.pack 的应用URI的帮助下检查是否安装了软件包我认为这是你想要的东西:

 private boolean appInstalledOrNot(String uri) {
    PackageManager pm = getPackageManager();
    boolean app_installed;
    try {
        pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES);
        app_installed = true;
    }
    catch (PackageManager.NameNotFoundException e) {
        app_installed = false;
    }
    return app_installed;
}