单击主页按钮时未显示Android应用程序[最近]

时间:2016-10-22 17:33:08

标签: android android-activity

我注意到我的应用有一种奇怪的行为。每当我按下主页按钮,我的应用程序就会被杀死。我在应用程序堆栈中看不到应用程序。我可以看到之前推出的其他应用程序。最初我怀疑android:launchMode="singleInstance"因此我将其更改为android:launchMode="singleTop",但这仍然无效。  这是我的清单文件。

  <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>

我的调试用完了。请建议如何调试此问题。

EDIT1: 这是我按下主页按钮的日志行:

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

请注意,有一个错误unknown buffer: 0x91dd4440我不确定该错误是什么。

EDIT2 : 我尝试将日志语句放在onPause()onDestroy()方法中。我看到onPause()日志语句,但我没有看到onDestroy()日志语句。这真的很奇怪,因为当我检查应用程序堆栈时,我看不到我的应用程序。当我尝试按后退按钮去我的应用程序不存在。

解决方案 我只是把艾哈迈德的解决方案放在这里,所以读者不必一直滚动到底部。 我的主要活动配置启用了此标志android:excludeFromRecents="true",导致在用户导航到其他应用程序时未在应用程序堆栈上显示应用程序。将此标记设置为falseandroid:excludeFromRecents="false")后,它再次开始工作。 以下是Android文档中有关此标志的说明:

是否应从最近使用的应用程序列表(概述屏幕)中排除此活动启动的任务。也就是说,当此活动是新任务的根活动时,此属性确定该任务是否不应出现在最近的应用列表中。设置&#34; true&#34;如果任务应从列表中排除;设置&#34;假&#34;如果它应该包括在内。默认值为&#34; false&#34;。

2 个答案:

答案 0 :(得分:1)

那么, 确保你没有这个

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

用于您的主要活动。 您将其设为android:label="@string/app_name" ,尝试将其设为android:label="MyApp"

此外,

确保您有此活动

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

您可以尝试将此设置为

android:excludeFromRecents="false" 而不是真实。

答案 1 :(得分:0)

分享更多信息。同时,仔细检查您的设备是否未设置为在休假(Settings > Developer Settings > (Apps tab) > Don't keep activities)时终止您的应用。