Reputation: 13588
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.
Upvotes: 3
Views: 3326
Reputation: 2304
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);
Upvotes: 3
Reputation: 2078
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.
Upvotes: 1
Reputation: 109237
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..
Upvotes: 3