Nolesh Nolesh - 1 month ago 266
Android Question

Install apk without downloading

Can I install

apk
file without downloading? The
apk
file is on the server. I tried the code below but it doesn't work:

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);
}


Where
uri
is
http://192.168.43.1:6789/mobile_base/test.apk
.
It returns an error:

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 }


If you have some thoughts you can share with me. Thanks.

Answer

you can use this code .may be solve the problem

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