1

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.

Rushikant Pawar
  • 428
  • 1
  • 5
  • 14
  • The process thing definitely isn't what you want. That runs your activity in a new process (I didn't actually know it could be used with activities, its usually used with services) that basically would mean its starting a new copy of your app with no links (including any variables you wrote) to the previous one. – Gabe Sechan Feb 22 '20 at 07:19

1 Answers1

2

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

Gabe Sechan
  • 90,003
  • 9
  • 87
  • 127
  • How can use FLAG_ACTIVITY_NEW_DOCUMENT| FLAG_ACTIVITY_MULTIPLE_TASKS when user touches app icon to start it? – Rushikant Pawar Feb 22 '20 at 07:31
  • Check edit 2. I think i need a attribute in my manifest rather than FLAGS – Rushikant Pawar Feb 22 '20 at 07:36
  • 1
    Your call activity isn't your launcher activity. So it wouldn't be launched when the user touches the app icon, mainactivity would be. – Gabe Sechan Feb 22 '20 at 07:50
  • @Gebe, Check My edited manifest code my both activities are category.DEFAULT, so it is launching it, and as a phone app my app needed these 2 activities to be category.DEFAULT – Rushikant Pawar Feb 22 '20 at 07:59
  • My call activity isn't my launcher activity, but it is already launched as call is going on. And now i want to open my app, so when i opens my app, i see my call activity, instead my my activity, And i want to see my main activity – Rushikant Pawar Feb 22 '20 at 08:26
  • I think you need to sit and think how to clearly state what you want. You seem to be self contradictory there. – Gabe Sechan Feb 22 '20 at 08:51
  • I sincerly thanks you, but in the meanwhile i also kept trying and solved the issue, i am editing my own question and inserting solution there, though i must thank you for your valueable time – Rushikant Pawar Feb 22 '20 at 09:08