android - programatically install a external APK
I am trying to see if it is possible to download and install an apk file and I got as far as testing with an included apk file in the resources folder. I try:
btnGo.addEventListener('click', function() {
var intent = Ti.Android.createIntent({
action: Ti.Android.ACTION_VIEW,
data: 'myapp2.apk',
type: "application/vnd.android.package-archive"
});
Ti.Android.currentActivity.startActivity(intent);
});
but it falls over with ActivityNotFoundException: No Activity found to handle Intent. I am pretty sure this is straigtforward in java, but why not Titanium?
6 Answers
-
Hello,
i think i found the solution for that problem and managed to work for me,
so i do this:var intent = Ti.Android.createIntent({ action: Ti.Android.ACTION_VIEW, data: 'file:///mnt/sdcard/download/yourapkfile.apk', type: "application/vnd.android.package-archive", packageName: "com.android.packageinstaller", flag: "0x10000000" }); Ti.Android.currentActivity.startActivity(intent);i added the packageName and the flag.
i found this by using the download manager from gmail and see what was happening in the log, then i tried to add the packageName and flag and it worked :)But first you need to download the apk to your sdcard.
It still need the input from te user to continue to install.
-
I've got the same issue…
Do you solve it? -
Hello,
Did u find an answer ? I've got the same issue…
-
Hello,
I also have the same problem.
As soon i use data: or type: in Ti.Android.createIntent i get: ActivityNotFoundException.
I hope someone has a solution. -
@chi xuan, sometimes i had problems with Ti.Filesystem.applicationDataDirectory, then i changed to the sdcard and it works very well. Im glad to help.
-
Does anyone know how to launch the package installed from the app ?