Android handle cancel event when app install

℡╲_俬逩灬. 提交于 2019-12-23 03:26:13

问题


I install apk file from folder programatically in such way:

File file = new File(apkFilePath);
    if (file.exists()) {
        try {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse("file://" + apkFilePath),
                    "application/vnd.android.package-archive");
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent);
        } catch (Exception e) {
            Log.d(TAG, "install error: " + e.toString());
        }
    } else {
        Log.d(TAG, "File doesn't exist ");
    }

When dialog appear there are two buttons "Install" and "Cancel". I need to catch cancel event. I try to register broadcast receiver but can't find appropriate event for cancel install action.

来源:https://stackoverflow.com/questions/45893356/android-handle-cancel-event-when-app-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!