安装apk而不下载

Nol*_*esh 0 streaming android client-server

我可以apk不下载安装文件吗?该apk文件位于服务器上.我尝试了下面的代码,但它不起作用:

public static void InstallProgram(Uri uri, Context context){
    Intent intent = new Intent(Intent.ACTION_VIEW);           
    intent.setDataAndType(uri,"application/vnd.android.package-archive");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);     
    context.startActivity(intent);
}
Run Code Online (Sandbox Code Playgroud)

哪里urihttp://192.168.43.1:6789/mobile_base/test.apk.它返回一个错误:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://192.168.43.1:6789/mobile_base/test.apk typ=application/vnd.android.package-archive flg=0x10000000 }
Run Code Online (Sandbox Code Playgroud)

如果你有一些想法,你可以与我分享.谢谢.

Ami*_*mar 5

你可以使用这个代码.可以解决问题

Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://192.168.43.1:6789/mobile_base/test.apk"));
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)