I'm trying to install packages on my device (from a device-owner app that runs on it) only by using the PackageInstaller and PackageManager APIs. I have been looking for examples but couldn't find anything that fit my need.
Here is a sample of my code to install the Facebook app:
PackageManager pm = getPackageManager();
PackageInstaller mPackageInstaller = pm.getPackageInstaller();
PackageInstaller.SessionParams mSessionParams = new PackageInstaller.SessionParams(SessionParams.MODE_FULL_INSTALL);
mSessionParams.setReferrerUri(Uri.parse("file:///mnt/sdcard/Download/Facebook.apk"));
int mSessionId = mPackageInstaller.createSession( mSessionParams );
PackageInstaller.Session mPkgSession = PackageInstaller.openSession(mSessionId);
OutputStream mOStream = mPkgSession.openWrite("com.facebook.katana", 0, -1);
mPkgSession.fsync(mOStream);
I guess, the next function I need to launch is a "commit(IntentSender statusReceiver)".
So Please tell me how to use commit() and especially how to declare a proper IntentSender to install the APK which is stored in /sdcard.
Thanks !!