blob: 78a4dfd47b4051728e920faee3fe736bbc60cc17 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080023
24/**
Dianne Hackborn271c2fe2011-08-09 19:35:13 -070025 * A screen that contains and runs multiple embedded activities.
26 *
Dianne Hackborn2f048832011-06-16 13:31:57 -070027 * @deprecated Use the new {@link Fragment} and {@link FragmentManager} APIs
28 * instead; these are also
29 * available on older platforms through the Android compatibility package.
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080030 */
Dianne Hackborn2f048832011-06-16 13:31:57 -070031@Deprecated
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032public class ActivityGroup extends Activity {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080033 private static final String STATES_KEY = "android:states";
34 static final String PARENT_NON_CONFIG_INSTANCE_KEY = "android:parent_non_config_instance";
35
36 /**
37 * This field should be made private, so it is hidden from the SDK.
38 * {@hide}
39 */
40 protected LocalActivityManager mLocalActivityManager;
41
42 public ActivityGroup() {
43 this(true);
44 }
45
46 public ActivityGroup(boolean singleActivityMode) {
47 mLocalActivityManager = new LocalActivityManager(this, singleActivityMode);
48 }
49
50 @Override
51 protected void onCreate(Bundle savedInstanceState) {
52 super.onCreate(savedInstanceState);
53 Bundle states = savedInstanceState != null
54 ? (Bundle) savedInstanceState.getBundle(STATES_KEY) : null;
55 mLocalActivityManager.dispatchCreate(states);
56 }
57
58 @Override
59 protected void onResume() {
60 super.onResume();
61 mLocalActivityManager.dispatchResume();
62 }
63
64 @Override
65 protected void onSaveInstanceState(Bundle outState) {
66 super.onSaveInstanceState(outState);
67 Bundle state = mLocalActivityManager.saveInstanceState();
68 if (state != null) {
69 outState.putBundle(STATES_KEY, state);
70 }
71 }
72
73 @Override
74 protected void onPause() {
75 super.onPause();
76 mLocalActivityManager.dispatchPause(isFinishing());
77 }
78
79 @Override
80 protected void onStop() {
81 super.onStop();
82 mLocalActivityManager.dispatchStop();
83 }
84
85 @Override
86 protected void onDestroy() {
87 super.onDestroy();
88 mLocalActivityManager.dispatchDestroy(isFinishing());
89 }
90
91 /**
92 * Returns a HashMap mapping from child activity ids to the return values
93 * from calls to their onRetainNonConfigurationInstance methods.
94 *
95 * {@hide}
96 */
97 @Override
98 public HashMap<String,Object> onRetainNonConfigurationChildInstances() {
99 return mLocalActivityManager.dispatchRetainNonConfigurationInstance();
100 }
101
102 public Activity getCurrentActivity() {
103 return mLocalActivityManager.getCurrentActivity();
104 }
105
106 public final LocalActivityManager getLocalActivityManager() {
107 return mLocalActivityManager;
108 }
109
110 @Override
111 void dispatchActivityResult(String who, int requestCode, int resultCode,
112 Intent data) {
113 if (who != null) {
114 Activity act = mLocalActivityManager.getActivity(who);
115 /*
Joe Onorato43a17652011-04-06 19:22:23 -0700116 if (false) Log.v(
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800117 TAG, "Dispatching result: who=" + who + ", reqCode=" + requestCode
118 + ", resCode=" + resultCode + ", data=" + data
119 + ", rec=" + rec);
120 */
121 if (act != null) {
122 act.onActivityResult(requestCode, resultCode, data);
123 return;
124 }
125 }
126 super.dispatchActivityResult(who, requestCode, resultCode, data);
127 }
128}
129
130