I have an app in which i use zxing barcode scanner
to scan qr codes
. This works only if the user installs barcode scanner
app in his mobile. So, can i install that app automatically with the installation of my app? Like installing apk file
programmatically or integrating that apk with mine etc. so that user need to again install that app manually.

- 13,560
- 9
- 60
- 109
3 Answers
Installation Code ....
String vsName=Environment.getExternalStorageDirectory().getAbsolutePath()+"/download/";
File file = new File(vsName, "aaa.apk");
System.out.println(":"+file);
Intent install=new Intent(Intent.ACTION_VIEW);
install.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(install);

- 8,440
- 5
- 49
- 69

- 2,294
- 3
- 17
- 22
Yes, I think you can, Put that apk in your internal storage and then using intent You can install it with programatically, First check with Android Package Manager if Barcode Scanner is available in device or not if not then install it,
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(path+"/Bscanner.apk")), "application/vnd.android.package-archive");
startActivity(intent);
But If possible you have to integrate the Zxing library into your android application and use it, So you have to no need to install Bar-code Scanner apk on device..

- 108,599
- 23
- 164
- 151
-
i mean in raw folder or something like that\ – Seshu Vinay Dec 14 '11 at 06:51
-
How can i access it if i copy it in assets? – Seshu Vinay Dec 14 '11 at 06:56
-
i mean how can i change the line intent.setDataAndType(Uri.fromFile(new File(path+"/Bscanner.apk")), "application/vnd.android.package-archive"); – Seshu Vinay Dec 14 '11 at 06:57
-
so if save in internal storage, it will be created automatically when i install my app? – Seshu Vinay Dec 14 '11 at 07:01
-
Yes, You ave to copy that apk in getDataDirectory() that will create a files directory in your app's internal storage.. – user370305 Dec 14 '11 at 07:04
You could have the user install your app and upon first run launch an Intent
to download the other app. The user would have to manually install the app but at least it would be automatically downloaded.
Edit: user370305's Intent
solution seems like a good way to initiate an installation. Since all downloads are in a shared directory on the sdcard, you could launch the install from the downloads directory.

- 2,078
- 2
- 15
- 20