ActivityGroup.java revision 2f04883ff880966d63d1aa4a1c7b05e497cfcc58
1/* 2 * Copyright (C) 2007 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 17package android.app; 18 19import java.util.HashMap; 20 21import android.content.Intent; 22import android.os.Bundle; 23import android.util.Log; 24 25/** 26 * @deprecated Use the new {@link Fragment} and {@link FragmentManager} APIs 27 * instead; these are also 28 * available on older platforms through the Android compatibility package. 29 * 30 * A screen that contains and runs multiple embedded activities. 31 */ 32@Deprecated 33public class ActivityGroup extends Activity { 34 private static final String TAG = "ActivityGroup"; 35 private static final String STATES_KEY = "android:states"; 36 static final String PARENT_NON_CONFIG_INSTANCE_KEY = "android:parent_non_config_instance"; 37 38 /** 39 * This field should be made private, so it is hidden from the SDK. 40 * {@hide} 41 */ 42 protected LocalActivityManager mLocalActivityManager; 43 44 public ActivityGroup() { 45 this(true); 46 } 47 48 public ActivityGroup(boolean singleActivityMode) { 49 mLocalActivityManager = new LocalActivityManager(this, singleActivityMode); 50 } 51 52 @Override 53 protected void onCreate(Bundle savedInstanceState) { 54 super.onCreate(savedInstanceState); 55 Bundle states = savedInstanceState != null 56 ? (Bundle) savedInstanceState.getBundle(STATES_KEY) : null; 57 mLocalActivityManager.dispatchCreate(states); 58 } 59 60 @Override 61 protected void onResume() { 62 super.onResume(); 63 mLocalActivityManager.dispatchResume(); 64 } 65 66 @Override 67 protected void onSaveInstanceState(Bundle outState) { 68 super.onSaveInstanceState(outState); 69 Bundle state = mLocalActivityManager.saveInstanceState(); 70 if (state != null) { 71 outState.putBundle(STATES_KEY, state); 72 } 73 } 74 75 @Override 76 protected void onPause() { 77 super.onPause(); 78 mLocalActivityManager.dispatchPause(isFinishing()); 79 } 80 81 @Override 82 protected void onStop() { 83 super.onStop(); 84 mLocalActivityManager.dispatchStop(); 85 } 86 87 @Override 88 protected void onDestroy() { 89 super.onDestroy(); 90 mLocalActivityManager.dispatchDestroy(isFinishing()); 91 } 92 93 /** 94 * Returns a HashMap mapping from child activity ids to the return values 95 * from calls to their onRetainNonConfigurationInstance methods. 96 * 97 * {@hide} 98 */ 99 @Override 100 public HashMap<String,Object> onRetainNonConfigurationChildInstances() { 101 return mLocalActivityManager.dispatchRetainNonConfigurationInstance(); 102 } 103 104 public Activity getCurrentActivity() { 105 return mLocalActivityManager.getCurrentActivity(); 106 } 107 108 public final LocalActivityManager getLocalActivityManager() { 109 return mLocalActivityManager; 110 } 111 112 @Override 113 void dispatchActivityResult(String who, int requestCode, int resultCode, 114 Intent data) { 115 if (who != null) { 116 Activity act = mLocalActivityManager.getActivity(who); 117 /* 118 if (Config.LOGV) Log.v( 119 TAG, "Dispatching result: who=" + who + ", reqCode=" + requestCode 120 + ", resCode=" + resultCode + ", data=" + data 121 + ", rec=" + rec); 122 */ 123 if (act != null) { 124 act.onActivityResult(requestCode, resultCode, data); 125 return; 126 } 127 } 128 super.dispatchActivityResult(who, requestCode, resultCode, data); 129 } 130} 131 132 133