user1302569
user1302569

Reputation: 7191

Run second application from first application android

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:

@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();
}

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?

Upvotes: 2

Views: 231

Answers (1)

dilix
dilix

Reputation: 3893

Check for intent flags: http://developer.android.com/reference/android/content/Intent.html

I think FLAG_ACTIVITY_NO_HISTORY is what you want

Upvotes: 1

Related Questions