[android] 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 }

This question is related to android streaming client-server

The answer is


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

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

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to streaming

How to set bot's status Chrome hangs after certain amount of data transfered - waiting for available socket Best approach to real time http streaming to HTML5 video client Playing m3u8 Files with HTML Video Tag Live-stream video from one android phone to another over WiFi Install apk without downloading an attempt was made to access a socket in a way forbbiden by its access permissions. why? Download/Stream file from URL - asp.net Android video streaming example What is the difference between RTP or RTSP in a streaming server?

Examples related to client-server

Sending files using POST with HttpURLConnection How to convert from []byte to int in Go Programming Install apk without downloading java.io.InvalidClassException: local class incompatible: Java socket API: How to tell if a connection has been closed? How do multiple clients connect simultaneously to one port, say 80, on a server? Is there a WebSocket client implemented for Python? Sending POST data in Android What is a simple C or C++ TCP server and client example?