b.i
b.i

Reputation: 1107

android: detect if the user has canceled an app's installation

I want to detect if a user has downloaded an Android app, but he clicked the "Cancel" button instead of "Install". Is there a way to detect if the user has canceled the installation of any app?

Upvotes: 2

Views: 1477

Answers (4)

She Smile GM
She Smile GM

Reputation: 1322

You can't detect that, but in the onActivityResult() function, you can try to search if the application has been installed in the PackageManager, by then you can determine if it has been cancelled or not.

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    PackageManager packageManager = this.appContext.getPackageManager();
    List<PackageInfo> apps = packageManager.getInstalledPackages(0);
    for (int i = 0; i < apps.size(); i++) {
        PackageInfo file = apps.get(i);
        if (file.applicationInfo.loadLabel(packageManager)
                .toString().equals("nameoftheapplicationtriedtoinstall")) {
            //then it has not cancelled, if it exist
        }
    }
}

Upvotes: 1

Anthony Graglia
Anthony Graglia

Reputation: 5435

This would have to be on Google Play and there is no API for this offered by them. It would be nice though.

Upvotes: 1

Andy Res
Andy Res

Reputation: 16043

I don't think that this is something you can detect from your application. I assume only the installer - program that performs the installation - could know this.

Upvotes: 0

Ramkumar
Ramkumar

Reputation: 91

There is no way like that.Instead of that u can able identify using particular button with pointer pressed or released.

Upvotes: 0

Related Questions