title: Execute Android application from native c code
body: <p>Continue my previous <a href="https://stackoverflow.com/questions/22781261/create-new-process-with-runtime-getruntime-in-android">question</a>, I succeeded to execute a process from an Android application. Now I can see two process like I wanted, they both up and running. Now I need to execute an Android application from the native C code.</p>
  
  <p>Found similar questions (<a href="https://stackoverflow.com/questions/17234244/execute-commands-via-c-code-in-android">1</a>, <a href="https://stackoverflow.com/questions/9530131/exec-command-android-native-code">2</a>), but the following solutions did NOT work for me.</p>
  
  <pre><code>1. execl("/system/bin/sh", "sh", "-c", "am start -a android.intent.action.MAIN -n   com.android.browser/.BrowserActivity", (char *)NULL);
  
  2. execl("/system/bin/am", "start", "-a", "android.intent.action.MAIN",
                   "-n", "com.android.settings/.Settings", (char *)NULL);
  </code></pre>
  
  <p>None of the lines above didn't executed anything.</p>
  
  <p>Even executing <code>execl</code> command with <code>fork</code> as follows did NOT help.</p>
  
  <pre><code>if (!fork()) {
      execl...
  }
  </code></pre>
  
  <p>Can you please give me some kind of a clue?
  Thanks.</p>
  
  <p><strong>UPDATE:</strong> I've manage to print the stdout to the Android log, I'm getting errno </p>
  
  <blockquote>
    <p>"Exec format error"</p>
  </blockquote>
  
  <p>message from the execl method. Anybody have an idea how I can resolve this?</p>