Rakesh Rakesh - 1 month ago 10
Android Question

Android application not shown when home button is clicked [Recents]

I have noticed a strange behavior for my app. Whenever I press the home button my app gets killed. I don't see the application in application stack. I can see other application which were launched earlier. Initially I doubted about the

android:launchMode="singleInstance"
so I changed it to
android:launchMode="singleTop"
but this still doesn't work.
Here is my manifest file entires.

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.my.finder.android.core"
android:installLocation="auto">



<application
android:name=".AndroidApplication"
android:allowBackup="false"
tools:replace="android:allowBackup"
android:icon="@mipmap/icon"
android:label="@string/app_name"
android:largeHeap="true"
android:theme="@style/Theme.MYTheme">


<activity
android:name=".Popup"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:process=":Popup"/>

<activity
android:name=".SignInActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:excludeFromRecents="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:taskAffinity=":extratask"
android:theme="@style/Theme.NoTitle">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
<!-- intent-filter for Optimizely -->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>

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

<data android:scheme="@string/optimizely_scheme"/>
</intent-filter>
<!-- this is the click_action of the push message (once kiln will support it, AFMI-13756) -->
<intent-filter>
<action android:name="OPEN_MAP_ACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

<activity
android:name=".FinderMapActivity"
android:launchMode="singleTop"
android:configChanges="orientation|keyboardHidden|screenSize"
android:exported="true"
android:screenOrientation="portrait"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:windowSoftInputMode="adjustPan">
</activity>
<activity
android:name=".LandingScreenActivity"
android:configChanges="keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:theme="@style/Theme.NoTitle">
</activity>
<activity
android:name=".fragment.SurveyFragmentActivity"
android:configChanges="keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:theme="@style/Theme.NoTitle">
</activity>
<activity
android:name=".SignupWelcomeActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:theme="@style/Theme.NoTitle"
android:windowSoftInputMode="adjustResize">
</activity>
<activity
android:name=".CreateAccountActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:theme="@style/Theme.NoTitle"
android:windowSoftInputMode="adjustResize">
</activity>
<activity
android:name=".AddAssetsActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:theme="@style/Theme.NoTitle"
android:windowSoftInputMode="adjustResize|stateHidden">
</activity>
<activity
android:name=".InviteCodeActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:theme="@style/Theme.NoTitle"
android:windowSoftInputMode="adjustResize">
</activity>
<activity
android:name=".IPhoneProvisioningActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:windowSoftInputMode="adjustResize">
</activity>
<activity
android:name=".ImproveLocationActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".CorporateLiableActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:theme="@style/Theme.NoTitle">
</activity>
<activity
android:name=".HistoryScreen"
android:configChanges="orientation|keyboardHidden"
android:launchMode="singleTop"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait"/>

<activity
android:name=".HistoryDetailScreen"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".ScheduleScreen"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".CreateScheduleScreen"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".activities.ScheduleCheckNotificationSettingsActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".ForgotPasswordActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:screenOrientation="portrait"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:theme="@style/Theme.NoTitle">
</activity>
<activity
android:name=".SettingsActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".WebviewDialog"
android:configChanges="orientation|keyboardHidden|screenSize"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>

<category android:name="android.intent.category.DEFAULT"/>

<data android:scheme="termsofservice"/>
</intent-filter>
</activity>
<activity
android:name=".PlaceScreen"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".PlaceDetailScreen"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".CreatePlaceActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".ChangePasswordActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:launchMode="singleTop"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize">
</activity>
<activity
android:name=".MyFamilyActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".ManageFamilyMemberActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".AddFamilyMemberActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".AddFamilyMembersActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".CancelServiceActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".CancelServiceFeedbackActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".DebugActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:launchMode="singleTop"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".signup.ContractActivity"
android:screenOrientation="portrait"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:theme="@style/Theme.NoTitle"
android:windowSoftInputMode="adjustResize">
</activity>
<activity
android:name=".OnboardingProgressActivity"
android:screenOrientation="portrait"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:theme="@style/Theme.NoTitle"
android:windowSoftInputMode="adjustResize">
</activity>

<activity android:name=".activities.PaywallActivity"
android:permission="com.my.permission.INTERNAL_ACTIVITES"
android:screenOrientation="portrait">
</activity>



</application>

</manifest>


I am running out of ideas for debugging. Please suggest how to debug this issue.

Edit1:
here is the log lines from the point where I press the home button:

10-22 10:54:27.352 6836-6923 E/Surface: getSlotFromBufferLocked: unknown buffer: 0x91dd4440
10-22 10:54:28.256 6836-7766 D/FA: Application backgrounded. Logging engagement
10-22 10:54:28.258 6836-7766 D/FA: Event not sent since app measurement is disabled


Notice that there is an error
unknown buffer: 0x91dd4440
I am not sure what is that error.

Edit2:
I tried to put the log statement in
onPause()
and
onDestroy()
method. I see
onPause()
log statements, but I don't see
onDestroy()
log statement. This is really strange because when I check the application stack I don't see my application. When I try to press back button to go to my application is not there.

Solution
I am just putting Ahmed's solution here so reader doesn't have to scroll all the way to the bottom.
My main activity configuration has this flag enabled
android:excludeFromRecents="true"
which was causing to not show the application on the application stack when user navigate to the other application. Once I set this flag to
false
(
android:excludeFromRecents="false"
) it started working again.
Here is the description about this flag from Android documentation:

Whether or not the task initiated by this activity should be excluded from the list of recently used applications, the overview screen. That is, when this activity is the root activity of a new task, this attribute determines whether the task should not appear in the list of recent apps. Set "true" if the task should be excluded from the list; set "false" if it should be included. The default value is "false".

Answer

Well, Make sure you don't have this

<activity.... android:label=""/>

for your Main activity. You set it android:label="@string/app_name" , try setting it as android:label="MyApp"

Also,

Make sure you have an activity with this

<action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />

You can try setting this to

android:excludeFromRecents="false" instead of true.

Comments