1 /* 2 * Copyright 2019 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package androidx.core.app 17 18 import android.os.Bundle 19 import android.view.WindowManager 20 import androidx.activity.ComponentActivity 21 import androidx.core.test.R 22 23 public class ActivityCompatRecreateLifecycleTestActivity : ComponentActivity() { onCreatenull24 override fun onCreate(savedInstanceState: Bundle?) { 25 super.onCreate(savedInstanceState) 26 27 window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) 28 setContentView(R.layout.activity_compat_activity) 29 } 30 onResumenull31 override fun onResume() { 32 super.onResume() 33 34 onResumeHandler?.invoke(this) 35 } 36 onStartnull37 override fun onStart() { 38 super.onStart() 39 40 onStartHandler?.invoke(this) 41 } 42 onStopnull43 override fun onStop() { 44 super.onStop() 45 46 onStopHandler?.invoke(this) 47 } 48 49 internal companion object { 50 var onResumeHandler: ((ActivityCompatRecreateLifecycleTestActivity) -> Unit)? = null 51 var onStartHandler: ((ActivityCompatRecreateLifecycleTestActivity) -> Unit)? = null 52 var onStopHandler: ((ActivityCompatRecreateLifecycleTestActivity) -> Unit)? = null 53 } 54 } 55