title: Android - Why is my activity being destroyed when my app is resumed?
body: <p>It only gets destroyed if I return to my app by tapping the icon. If I open the list of running apps and return to it from there, it resumes normally. I put a breakpoint at the onDestroy() function, because I can't find any of my code that gets called before it. Here's the thread it was called on:</p>
  
  <pre><code>onDestroy:500, CookActivity {com.mycompany.myapp}
  performDestroy:6228, Activity {android.app}
  callActivityOnDestroy:1157, Instrumentation {android.app}
  performDestroyActivity:3898, ActivityThread {android.app}
  handleDestroyActivity:3929, ActivityThread {android.app}
  access$1400:160, ActivityThread {android.app}
  handleMessage:1375, ActivityThread$H {android.app}
  dispatchMessage:102, Handler {android.os}
  loop:135, Looper {android.os}
  main:5597, ActivityThread {android.app}
  invoke:-1, Method {java.lang.reflect}
  invoke:372, Method {java.lang.reflect}
  run:984, ZygoteInit$MethodAndArgsCaller {com.android.internal.os}
  main:779, ZygoteInit {com.android.internal.os}
  </code></pre>
  
  <p>It looks like it's receiving some message to destroy my activity from somewhere. In the Looper there's a variable called msg. This is it's value:</p>
  
  <pre><code>{ when=-5m57s667ms what=109 arg1=1 obj=android.os.BinderProxy@1433d777 target=android.app.ActivityThread$H }
  </code></pre>
  
  <p>Does anyone know what's happening here? How do I make my app resume normally like it does when I select it from the running app list?</p>
  
  <p>Edit: As requested, here is the AndroidManifest.xml file:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mycompany.myapp"&gt;
  
      &lt;uses-permission android:name="android.permission.INTERNET" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.VIBRATE" /&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
      &lt;uses-permission android:name="android.permission.READ_PHONE_STATE" /&gt;
  
  
      &lt;uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt;
  
      &lt;application
          android:name=".App"
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:roundIcon="@mipmap/ic_launcher_round"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
          &lt;activity
              android:name=".MainActivity"
              android:configChanges="orientation|keyboardHidden|screenSize"
              android:label="@string/app_name"
              android:launchMode="singleTask"
              android:theme="@style/MainTheme"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=".CookActivity"
              android:configChanges="orientation|keyboardHidden|screenSize"
              android:label="@string/title_activity_cook"
              android:launchMode="singleTop"
              android:parentActivityName=".MainActivity"&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=".AlarmActivity"
              android:excludeFromRecents="true"
              android:showOnLockScreen="true"
              android:showForAllUsers="true"
              android:theme="@style/AlarmTheme"&gt;
          &lt;/activity&gt;
  
          &lt;service android:name=".MyFirebaseMessagingService"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.firebase.MESSAGING_EVENT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/service&gt;
          &lt;service android:name=".MyFirebaseInstanceIDService"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="com.google.firebase.INSTANCE_ID_EVENT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/service&gt;
          &lt;service android:name="org.eclipse.paho.android.service.MqttService" /&gt;
  
          &lt;provider
              android:name="android.support.v4.content.FileProvider"
              android:authorities="${applicationId}.provider"
              android:exported="false"
              android:grantUriPermissions="true"&gt;
              &lt;meta-data
                  android:name="android.support.FILE_PROVIDER_PATHS"
                  android:resource="@xml/provider_paths"/&gt;
          &lt;/provider&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>