title: Install apk in android device from java code
body: <p>I am trying to make a simple application in Java to install an APK on Android devices connected via USB. Using ABD manually or installing from Android Studio it works fine, but I wanted to give a simple single button click install option within my application, I have tried following code but unfortunately, it is not working</p>
  
  <pre><code>    abdsourcesync = apkpath;
      progress.setString("sync in progress");
      System.out.println("Starting Sync via adb with command " + "adb"
              + " install -r " + apkpath);
  
      Process process = Runtime.getRuntime().exec(
              "adb" + " install -r " + apkpath);
      InputStreamReader reader = new InputStreamReader(
              process.getInputStream());
      Scanner scanner = new Scanner(reader);
      scanner.close();
      int exitCode = process.waitFor();
      System.out.println("Process returned: " + exitCode);
  </code></pre>
  
  <p>I have searched around here but  I have only found installing an APK from within an Android application or from the android studio, not from a  core Java. or java web module </p>
  
  <p>Your helping hand  would be really appreciated ;</p>