1 /* 2 * Copyright (C) 2020 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 com.android.tests.UidImportanceHelper; 17 18 import android.app.Activity; 19 import android.content.Intent; 20 import android.os.Bundle; 21 import android.util.Log; 22 23 /** 24 * This is an empty activity for testing the UID policy of media transcoding service. 25 */ 26 public class MainActivity extends Activity { 27 private static final String TAG = "MainActivity"; 28 29 // Called at the start of the full lifetime. 30 @Override onCreate(Bundle savedInstanceState)31 public void onCreate(Bundle savedInstanceState) { 32 super.onCreate(savedInstanceState); 33 // Initialize Activity and inflate the UI. 34 } 35 36 // Called after onCreate has finished, use to restore UI state 37 @Override onRestoreInstanceState(Bundle savedInstanceState)38 public void onRestoreInstanceState(Bundle savedInstanceState) { 39 super.onRestoreInstanceState(savedInstanceState); 40 // Restore UI state from the savedInstanceState. 41 // This bundle has also been passed to onCreate. 42 // Will only be called if the Activity has been 43 // killed by the system since it was last visible. 44 } 45 46 // Called before subsequent visible lifetimes 47 // for an activity process. 48 @Override onRestart()49 public void onRestart() { 50 super.onRestart(); 51 // Load changes knowing that the Activity has already 52 // been visible within this process. 53 } 54 55 // Called at the start of the visible lifetime. 56 @Override onStart()57 public void onStart() { 58 super.onStart(); 59 // Apply any required UI change now that the Activity is visible. 60 } 61 62 // Called at the start of the active lifetime. 63 @Override onResume()64 public void onResume() { 65 super.onResume(); 66 // Resume any paused UI updates, threads, or processes required 67 // by the Activity but suspended when it was inactive. 68 } 69 70 // Called to save UI state changes at the 71 // end of the active lifecycle. 72 @Override onSaveInstanceState(Bundle savedInstanceState)73 public void onSaveInstanceState(Bundle savedInstanceState) { 74 // Save UI state changes to the savedInstanceState. 75 // This bundle will be passed to onCreate and 76 // onRestoreInstanceState if the process is 77 // killed and restarted by the run time. 78 super.onSaveInstanceState(savedInstanceState); 79 } 80 81 // Called at the end of the active lifetime. 82 @Override onPause()83 public void onPause() { 84 // Suspend UI updates, threads, or CPU intensive processes 85 // that don't need to be updated when the Activity isn't 86 // the active foreground Activity. 87 super.onPause(); 88 } 89 90 // Called at the end of the visible lifetime. 91 @Override onStop()92 public void onStop() { 93 // Suspend remaining UI updates, threads, or processing 94 // that aren't required when the Activity isn't visible. 95 // Persist all edits or state changes 96 // as after this call the process is likely to be killed. 97 super.onStop(); 98 } 99 100 // Sometimes called at the end of the full lifetime. 101 @Override onDestroy()102 public void onDestroy() { 103 // Clean up any resources including ending threads, 104 // closing database connections etc. 105 super.onDestroy(); 106 } 107 } 108