Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to install downloaded apk through code in android?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 115
    Comment on it

    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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: