I see where you are trying to go, but I think you need to rethink the approach a bit. You should always allow your users to install and uninstall at their discretion. But you can put a check in the application to see when the application was first installed.
PackageInfo info = pm.getPackageInfo(packageName, 0);
long firstInstallTime = info.firstInstallTime;
, firstInstallTime
.
PackageInfo .
, ( , ), :
ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(packageName, 0);
long mostRecentInstallTime = new File(appInfo.sourceDir).lastModified();
, 1- , " ", , .
:
...
PackageInfo , . PackageInfo , , , " ".
firstInstallTime :
List<PackageInfo> packageInfoInstalledPackages = getPackageManager().getInstalledPackages(0);
long[] firstInstallTimes = long[packageInfoInstalledPackages.size()];
for(int i=0;i<packageInfoInstalledPackages.size();i++) {
PackageInfo p = packageInfoInstalledPackages.get(i);
if (p.versionName != null) {
firstInstallTimes[i] = p.firstInstallTime;
}
}
ApplicationInfo, , .