Run second application from first application android
<p>I have two applications on my phone. I run First and I want to this first run my second application. This is code from my first application:</p>

<pre><code>@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    PackageManager pm = getPackageManager();
    Intent intent = pm.getLaunchIntentForPackage("com.example.p2a");
    intent.putExtra("application_id", 2);
    getApplicationContext().startActivity(intent);
    finish();
}
</code></pre>

<p>Everything works great but I want to when I start again my first application and my second application is hide I want to start my second application from beginning. I think about when I run first application I check if second application is running I want to kill that app, but I can' t do that. How I can start application again, not run from "onResume" method?</p>
