I am trying to install apk programmatically from SD card without mentioning the name of the apk. What I can do now is I can get installed the apk I named in my code. But it is not handy if I want to have another apk installed on my device and for that I have to go into my code and change the name of the apk. Is there any way to get the name of the apk file dynamically on run time? For instance getting a list of installable apk, so that user can choose which one to install?
Intent intent = new Intent();
intent.setAction(android.content.Intent.ACTION_VIEW);
intent.setDataAndType(
Uri.parse("file:///mnt/sdcard/extsd/download /app.apk"),
"application/vnd.android.package-archive");
startActivity(intent);
Update: The previous code was deleted because contain errors. Here is a working code:
Update 2:
This program simply enumerates all apk file and writes them to the array of File. After that it tries to install all this apk files sequentially. For instance, in my case I put application golddream.apk on a sdcard of my emulator. The application is developed for SDK v 10. I see the following output in my logcat: