如何以编程方式安装apk文件 [英] how to install apk file programmatically
本文介绍了如何以编程方式安装apk文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从我的应用程序安装apk文件。
我已经创建了一个应用程序,其中包含一个按钮,当我点击该按钮,然后另外一个APK
我已经存储在资源文件夹应安装,
继承人的东西我已经做了:
公共无效的onClick(视图v){
//意向意图=新的意图(com.google.zxing.client.android.SCAN);
// intent.setPackage(com.google.zxing.client.android);
// intent.putExtra(SCAN_MODE,QR_ code_MODE);
// startActivityForResult(意向,0);
档案文件=新的文件(android.resource://com.app.bar$c$cscanner/raw,scan.apk);
意向意图=新的意图(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(文件),应用程序/ vnd.android.package存档);
startActivity(意向);
}
什么想法? 请帮我这个
解决方案
意向意图=新的意图(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(新文件
(Environment.getExternalStorageDirectory()+/bar$c$c.apk)),应用程序/ vnd.android.package存档);
startActivity(意向);
I want to install an apk file from my application.
I have created an app that contains a button, when I click that button then another apk
that I have stored in resources folder should be install,
Heres something I have done :
public void onClick(View v) {
// Intent intent = new Intent("com.google.zxing.client.android.SCAN");
// intent.setPackage("com.google.zxing.client.android");
// intent.putExtra("SCAN_MODE", "QR_CODE_MODE");
// startActivityForResult(intent, 0);
File file = new File("android.resource://com.app.barcodescanner/raw", "scan.apk");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
startActivity(intent);
}
any ideas ?
please help me with this
解决方案
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File
(Environment.getExternalStorageDirectory() + "/barcode.apk")), "application/vnd.android.package-archive");
startActivity(intent);
这篇关于如何以编程方式安装apk文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文