I'am trying to install apk silently without any prompt.
This is the code which installs the apk file by using adb command.
public void InstallAPK(String filename){
File file = new File(filename);
if(file.exists()){
try {
String command;
command = "adb install -r " + filename;
Process proc = Runtime.getRuntime().exec(new String[] { "su", "-c", command });
proc.waitFor();
} catch (Exception e) {
e.printStackTrace();
}
}
}
But when I run this code, I am getting the following error.
java.io.IOException: Error running exec(). Command: [su, -c, adb install -r /storage/emulated/0/Download/sampleapp.apk] Working Directory: null Environment: null
I have given these permissions.
<uses-permission android:name="android.permission.INSTALL_PACKAGES"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
Please can someone help me to solve this error.