3

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.

Seshu Vinay
  • 13,560
  • 9
  • 60
  • 109

3 Answers3

3

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);
Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69
Md Maidul Islam
  • 2,294
  • 3
  • 17
  • 22
3

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..

user370305
  • 108,599
  • 23
  • 164
  • 151
1

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.

Jasoneer
  • 2,078
  • 2
  • 15
  • 20