Install apk without downloading

1

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 }
android
streaming
client-server
asked on Stack Overflow Jun 8, 2012 by Nolesh • edited Jan 20, 2020 by Trilarion

2 Answers

5

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);
answered on Stack Overflow Jun 8, 2012 by Amit kumar
2

For this your android application must have uploaded into the android market. when you upload it on the android market then use the following code to open the market with your android application.

    Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("market://details?id=<packagename>"));
startActivity(intent);

If you want it to download and install from your own server then use the following code

Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://www.example.com/sample/test.apk"));
    startActivity(intent);
answered on Stack Overflow Jun 8, 2012 by Amit Thaper

User contributions licensed under CC BY-SA 3.0