title: Exception with Install APK programmatically
body: <p>Am trying to develop a android app for Google Glass which pulls apk from remote server, uninstalls and re-installs.</p>
  
  <p>Glass is rooted, I installed installer app in /system/app, I signed the app by creating keystore file from cert &amp; pk8 files,</p>
  
  <p>keystore files, </p>
  
  <ol>
  <li>platform.pk8</li>
  <li>platform.x509.pem</li>
  </ol>
  
  <p><a href="https://android.googlesource.com/platform/build/+/android-4.4.2_r2.0.1/target/product/security" rel="nofollow">https://android.googlesource.com/platform/build/+/android-4.4.2_r2.0.1/target/product/security</a></p>
  
  <p>Code I followed in installer apk to install, </p>
  
  <pre><code>private void install(String result) throws Exception{
      text.setText("Installing...");
      final String libs = "LD_LIBRARY_PATH=/vendor/lib:/system/lib ";
      final String[] commands = {
              libs + "pm install --user -1 -r " + result
              //        ,libs + "am start -n " + context.getPackageName() + "/" + get_main_activity()
      };
  
  
      File file = new File(result);
      if (file.exists()){
          Log.d(TAG,"Found file" + file.getAbsolutePath());
      }else{
          Log.d(TAG, "File not found");
      }
  
  
  
  
     execute_as_root(commands);
  
  
  }
  
  private void execute_as_root( String[] commands ) throws Exception{
      try {
          // Do the magic
          Process p = Runtime.getRuntime().exec( "su" );
          InputStream es = p.getErrorStream();
          DataOutputStream os = new DataOutputStream(p.getOutputStream());
  
          for( String command : commands ) {
              //Log.i(TAG,command);
              os.writeBytes(command + "\n");
          }
          os.writeBytes("exit\n");
          os.flush();
          os.close();
  
          int read;
          byte[] buffer = new byte[4096];
          String output = new String();
          while ((read = es.read(buffer)) &gt; 0) {
              output += new String(buffer, 0, read);
          }
  
          p.waitFor();
  
          Log.e(TAG, output.trim() + " (" + p.exitValue() + ")");
          text.setText("Done");
  
  
      } catch (IOException e) {
          Log.e(TAG, e.getMessage());
          e.printStackTrace();
      } catch (InterruptedException e) {
          Log.e(TAG, e.getMessage());
          e.printStackTrace();
      }finally{
          manager.release();
          finish();
      }
  }
  </code></pre>
  
  <p>I get into below exception </p>
  
  <pre><code>java.lang.SecurityException: Permission Denial: broadcast asks to run as user -1 but is calling from user 0; this requires android.permission.INTERACT_ACROSS_USERS_FULL or android.permission.INTERACT_ACROSS_USERS
                                                                                             at android.os.Parcel.readException(Parcel.java:1465)
                                                                                             at android.os.Parcel.readException(Parcel.java:1419)
                                                                                             at android.app.ActivityManagerProxy.broadcastIntent(ActivityManagerNative.java:2373)
                                                                                             at com.android.commands.am.Am.sendBroadcast(Am.java:810)
                                                                                             at com.android.commands.am.Am.onRun(Am.java:285)
                                                                                             at com.android.internal.os.BaseCommand.run(BaseCommand.java:47)
                                                                                             at com.android.commands.am.Am.main(Am.java:77)
                                                                                             at com.android.internal.os.RuntimeInit.nativeFinishInit(Native Method)
                                                                                             at com.android.internal.os.RuntimeInit.main(RuntimeInit.java:243)
                                                                                             at dalvik.system.NativeStart.main(Native Method)
                                                                                         Permission denied (1)
  </code></pre>
  
  <p>Manifest Permissions</p>
  
  <pre><code>&lt;uses-permission android:name="com.google.android.glass.permission.DEVELOPMENT" /&gt;
  &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  &lt;uses-permission android:name="android.permission.INSTALL_PACKAGES"/&gt;
  &lt;uses-permission android:name="android.permission.DELETE_PACKAGES"/&gt;
  &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
  &lt;uses-permission android:name="android.permission.DISABLE_KEYGUARD" /&gt;
  &lt;uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL"/&gt;
  </code></pre>