2

I have 2 apps, one of them is calling an activity from the second one through an intent filter like so:

Call in App1 (Parent app)

Intent openApp = new Intent("com.app.intent.Activity2");
startActivity(openApp );

Intent filter in App2 (child app)

    <activity
        android:name=".app.activity.Activity2"
        android:label="@string/app_name" 
        android:launchMode="singleInstance"
        >

        <intent-filter>
            <action android:name="com.app.intent.Activity2" />
            <category android:name="android.intent.category.BROWSABLE"/> 
            <category android:name="android.intent.category.DEFAULT"/> 
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

At one point the Parent application has to close but the problem is the Activity2 from the second application gets killed as well. I can see that Activity2 is actually running under the same package, is there any way to have the Activity2 persist and run even after the parent applicaiton is closed ?

Thank you

Fiur
  • 624
  • 1
  • 6
  • 20

2 Answers2

1

This discussion seems to have what you need. Seems like you need to get the launch intent from the package you want to launch and use that in your intent.

Launch an application from another application on Android

Community
  • 1
  • 1
Gophermofur
  • 2,073
  • 1
  • 12
  • 13
0

Android will generally run all components from the same APK in a single process, so if one of those crashes the process then they will all be gone.

You can however tell it to put an activity or service in its own process.

<activity
    android:name=".app.activity.Activity2"
    android:label="@string/app_name" 
    android:launchMode="singleInstance"
    android:process=":my_unique_process">

Of course if your process is dieing unexpectedly, that's a problem that needs to be understood and fixed - this would just be a temporary workaround.

Chris Stratton
  • 38,489
  • 6
  • 80
  • 115
  • These are not components from the same apk. One apk is calling an activity from another apk. None of them are dying unexpectedly. My problem is if app1 calls the Intent from app2, when app1 is closed the Intent from app2 gets killed as well and i don't want that. – Fiur Apr 25 '12 at 19:32
  • Perhaps you had better clarify what you mean by "closed" and "killed" – Chris Stratton Apr 25 '12 at 19:39