user7366285
user7366285

Reputation:

Android back button not working as intended after background

I have an activity A from which I start activity B.

If I press the back button it will go back to activity A, however if I press the home button or change to another app and come back to my app the back button closes the app instead, so I can no longer get back to activity A without restarting the app.

I use no flags when creating the intent.

Java:

Intent i = new Intent(this, InCallActivity.class);
startActivity(i);

XML:

<activity
    android:name=".MainScreenActivity"
    android:label="@string/app_name"
    android:launchMode="singleInstance"
    android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.intent.action.MANAGER" />
        <action android:name="android.intent.action.SEARCH" />
    </intent-filter>

    <meta-data
        android:name="android.app.searchable"
        android:resource="@xml/searchable" />
</activity>
<activity android:name=".InCallActivity"
          android:screenOrientation="portrait"
          android:launchMode="singleInstance"/>

Upvotes: 1

Views: 319

Answers (1)

aj0822ArpitJoshi
aj0822ArpitJoshi

Reputation: 1182

Please try removing the attribute android:launchMode="singleInstance" in your activities, and check if it works.

Follow these links for more information: Activity Syntax and Launch Mode

Upvotes: 1

Related Questions