由网友(冷面冷心冷温柔ゞ)分享简介:我想从我的应用程序安装apk文件。我已经创建了一个应用程序,其中包含一个按钮,当我点击该按钮,然后另外一个APK我已经存储在资源文件夹应安装,继承人的东西我已经做了:公共无效的onClick(视图v){//意向意图=新的意图(com.google.zxing.client.android.SCAN);// inte...
我想从我的应用程序安装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);
相关推荐
最新文章