1 /* 2 * Copyright 2017 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 17 package android.app.servertransaction; 18 19 import android.annotation.IntDef; 20 import android.annotation.NonNull; 21 import android.os.Parcel; 22 23 import java.lang.annotation.Retention; 24 import java.lang.annotation.RetentionPolicy; 25 26 /** 27 * Request for lifecycle state that an activity should reach. 28 * @hide 29 */ 30 public abstract class ActivityLifecycleItem extends ActivityTransactionItem { 31 32 @IntDef(prefix = { "UNDEFINED", "PRE_", "ON_" }, value = { 33 UNDEFINED, 34 PRE_ON_CREATE, 35 ON_CREATE, 36 ON_START, 37 ON_RESUME, 38 ON_PAUSE, 39 ON_STOP, 40 ON_DESTROY, 41 ON_RESTART 42 }) 43 @Retention(RetentionPolicy.SOURCE) 44 public @interface LifecycleState{} 45 public static final int UNDEFINED = -1; 46 public static final int PRE_ON_CREATE = 0; 47 public static final int ON_CREATE = 1; 48 public static final int ON_START = 2; 49 public static final int ON_RESUME = 3; 50 public static final int ON_PAUSE = 4; 51 public static final int ON_STOP = 5; 52 public static final int ON_DESTROY = 6; 53 public static final int ON_RESTART = 7; 54 ActivityLifecycleItem()55 ActivityLifecycleItem() {} 56 ActivityLifecycleItem(@onNull Parcel in)57 ActivityLifecycleItem(@NonNull Parcel in) { 58 super(in); 59 } 60 61 @Override isActivityLifecycleItem()62 public boolean isActivityLifecycleItem() { 63 return true; 64 } 65 66 /** A final lifecycle state that an activity should reach. */ 67 @LifecycleState getTargetState()68 public abstract int getTargetState(); 69 } 70