I am working on an application in which I have to restrict access to a personal apk user. It can be downloaded, but you should not allow application sharing (apk) via Bluetooth, etc.
I searched and read a lot about the same problem, but did not find a complete answer. I tried the following.
What I understood above is that an easy way to do this is to remove the apk file from the user device after installing the application. (I also know that the user can generate this apk again via root access, but this is normal, at least I can limit not everything, but many).
Now that I tried, I register the Broadcast receiver and in my method onReceive()I have below
PackageManager pm = getPackageManager();
for (ApplicationInfo app : pm.getInstalledApplications(0)) {
if (myPackage.equalsIgnoreCase(app.packageName)) {
apkPath = app.sourceDir;
break;
}
}
Log.d("Package", myPackage + " - APK - " + apkPath);
if (intent.getAction().equals("android.intent.action.PACKAGE_ADDED")) {
File sdcard = Environment.getExternalStorageDirectory();
File file = new File(sdcard, apkPath);
file.delete();
}
But this does nothing, because I do not know the IntentFilter, which I have to use to register this.
Can someone direct me to the next step? and if I'm completely on the wrong land, then help me reach higher?
Any help would be appreciated. :)
source
share