title: ViewModel functionality in 27.1.x broken with config changes on child activities
body: <p>I came across this bit of weird behavior and thought it might be of interest to the community. If you have a ViewModel defined for a parent activity, then start a child activity, do an orientation change (I'm using an emulator configured with API=24) and return to the parent activity, the ViewModel of the parent is destroyed and a brand new one is allocated to you by the ViewModelProviders.of method. This is clearly not what is supposed to happen. Might I be misuing this feature?</p>
  
  <p>Sample code to recreate the issue is below. The main activity displays a pointer to the ViewModel. Press the button to start the child activity, then do an orientation change, then press back to return to the parent activity. It will update the ViewModel pointer. On the other hand, if you do the orientation change from the parent activity, the ViewModel is not destroyed. Similarly, if you do an orientation change on the child activity, then do another one to undo it, the parent activity will retain the original ViewModel. Go figure.</p>
  
  <p>MainActivity.java</p>
  
  <pre><code>package com.google.example.viewmodeltest;
  
  import android.arch.lifecycle.ViewModelProviders;
  import android.content.Intent;
  import android.os.Bundle;
  import android.support.design.widget.FloatingActionButton;
  import android.support.design.widget.Snackbar;
  import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
  import android.view.View;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.TextView;
  
  import org.w3c.dom.Text;
  
  public class MainActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          MyViewModel viewModel=ViewModelProviders.of(this).get(MyViewModel.class);
          ((TextView) findViewById(R.id.infoText)).setText("ViewModel="+viewModel);
  
          findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  startActivity(new Intent(MainActivity.this,ChildActivity.class));
              }
          });
      }
  }
  </code></pre>
  
  <p>ChildActivity.java</p>
  
  <pre><code>package com.google.example.viewmodeltest;
  
  import android.os.Bundle;
  import android.support.annotation.Nullable;
  import android.support.v7.app.AppCompatActivity;
  
  public class ChildActivity extends AppCompatActivity {
      @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_child);
      }
  }
  </code></pre>
  
  <p>MyViewModel.java</p>
  
  <pre><code>package com.google.example.viewmodeltest;
  
  import android.arch.lifecycle.ViewModel;
  
  public class MyViewModel extends ViewModel {
      public MyViewModel() {
          super();
      }
  }
  </code></pre>
  
  <p>layout/activity_main.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"
      android:padding="5dp"&gt;
  
      &lt;TextView android:id="@+id/infoText"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"/&gt;
      &lt;Button android:id="@+id/button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Press"/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>layout/activity_child.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="This is the child activity"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Module build.gradle</p>
  
  <pre><code>apply plugin: 'com.android.application'
  
  android {
      compileSdkVersion 27
      defaultConfig {
          applicationId "com.google.example.viewmodeltest"
          minSdkVersion 14
          targetSdkVersion 27
          versionCode 1
          versionName "1.0"
          testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
      }
      buildTypes {
          release {
              minifyEnabled false
              proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
          }
      }
  }
  
  dependencies {
  //  def supportlib_version = "28.0.0-rc01"
      def supportlib_version = "27.1.1"
  
      implementation fileTree(dir: 'libs', include: ['*.jar'])
      implementation "com.android.support:appcompat-v7:$supportlib_version"
      implementation "com.android.support:design:$supportlib_version"
      implementation "com.android.support.constraint:constraint-layout:1.1.2"
      implementation "android.arch.lifecycle:extensions:1.1.1"
      annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
  
      testImplementation 'junit:junit:4.12'
      androidTestImplementation 'com.android.support.test:runner:1.0.2'
      androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
  }
  </code></pre>
  
  <p>AndroidManifest.xml</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.google.example.viewmodeltest"&gt;
  
      &lt;application
          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:label="@string/app_name"
              android:theme="@style/AppTheme.NoActionBar"&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=".ChildActivity" /&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>