process – Running android apps particular activity independently than rest of activities-ThrowExceptions

Exception or error:

THIS QUESTION IS SOLVED, PROVIDING ANSWER FOR FUTURE SO VISITORS BELOW

Context :

I am developing a default phone app. Which handles action.DIAL and action.CALL from My application as well as it handles these both intents from other apps too.

What is problem :

If my CallActivity is running ( if any call is ongoing ) then –

  1. When i again try to open my app, it is presenting me CallActivity only.
  2. And because of this i am unable to make another call by opening my app.

What manifest.xml looks like :

<application
    android:allowBackup="true"
    android:directBootAware="true"
    android:fullBackupContent="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.CALL_BUTTON" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity>

    <activity
        android:name=".CallActivity"
        android:label="@string/title_activity_call"
        android:process=":CallManager"
        android:screenOrientation="portrait"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter android:priority="800">
            <action android:name="android.intent.action.ACTION_CALL" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity>
</application> 

What i found when searched for the said problem :

What are my efforts taken :

You can note i tried android:process=":CallManager" attribute in manifest for my CallActivity

Did that solved the issue :

Nope. I am still unable to open my MainActivity, whenever CallActivity is running. But is caused the problem that now my call is not getting ended as this is completely another process it is unable to reference other calls which remain there in older process.

ANSWER

Did android:process was correct :

No not at all in this case, as it is used when our app memory usage increases over particular limit android starts caching its services and resources in order to avoid it developers generally use android:process which allows them another heap memory available with same heap size.

** What was problem :**

It was related to task and its affinities
Both activities needed to be separated for tasks and their affinities

like :

<activity
android:name="com.example.ActivityA"
android:label="Activity A"
android:launchMode="singleInstance"
android:taskAffinity="com.example.AffinityA" >
</activity>
<activity
android:name="com.example.ActivityB"
android:label="Activity B"
android:launchMode="singleInstance"
android:taskAffinity="com.example.AffinityB" >
</activity>

I must thanks @JayWozz for his answer over SO https://stackoverflow.com/a/45488126/9810130 and must appreciate @gabe-sechan for his sincere help and efforts and for giving his value-able time for this thread.

How to solve:

I think you’re basically asking for a new stack of activities. Try launching the intent with FLAG_ACTIVITY_NEW_DOCUMENT| FLAG_ACTIVITY_MULTIPLE_TASKS That will launch the activity as if its a new set of activities, with its own separate listing in the recent apps list. See the definiton of these flags at https://developer.android.com/reference/android/content/Intent

Leave a Reply

Your email address will not be published. Required fields are marked *