If you want to install the downloaded .apk from your device through java code than you just need the path and the name of that .apk, if you have these two thing (path and the name of that .apk) than you just need to use the code given below.
// Mention the name of the .apk file.
String name="TestApp.apk";
// First you need to check that file is present or not.
if(new File(Environment.getExternalStorageDirectory().getPath() + "/"+name).exists())
{
// Code to install the file.
String filepath = Environment.getExternalStorageDirectory().getPath() + "/"+name;
Uri fileLoc = Uri.fromFile(new File(filepath));
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(fileLoc, "application/vnd.android.package-archive");
getActivity().startActivity(intent);
}
0 Comment(s)