• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package android.app;
18 
19 import android.compat.annotation.UnsupportedAppUsage;
20 import android.content.Intent;
21 import android.os.Bundle;
22 
23 import java.util.HashMap;
24 
25 /**
26  * A screen that contains and runs multiple embedded activities.
27  *
28  * @deprecated Use the new {@link Fragment} and {@link FragmentManager} APIs
29  * instead; these are also
30  * available on older platforms through the Android compatibility package.
31  */
32 @Deprecated
33 public class ActivityGroup extends Activity {
34     private static final String STATES_KEY = "android:states";
35     static final String PARENT_NON_CONFIG_INSTANCE_KEY = "android:parent_non_config_instance";
36 
37     /**
38      * This field should be made private, so it is hidden from the SDK.
39      * {@hide}
40      */
41     @UnsupportedAppUsage
42     protected LocalActivityManager mLocalActivityManager;
43 
ActivityGroup()44     public ActivityGroup() {
45         this(true);
46     }
47 
ActivityGroup(boolean singleActivityMode)48     public ActivityGroup(boolean singleActivityMode) {
49         mLocalActivityManager = new LocalActivityManager(this, singleActivityMode);
50     }
51 
52     @Override
onCreate(Bundle savedInstanceState)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
onResume()61     protected void onResume() {
62         super.onResume();
63         mLocalActivityManager.dispatchResume();
64     }
65 
66     @Override
onSaveInstanceState(Bundle outState)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
onPause()76     protected void onPause() {
77         super.onPause();
78         mLocalActivityManager.dispatchPause(isFinishing());
79     }
80 
81     @Override
onStop()82     protected void onStop() {
83         super.onStop();
84         mLocalActivityManager.dispatchStop();
85     }
86 
87     @Override
onDestroy()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
onRetainNonConfigurationChildInstances()100     public HashMap<String,Object> onRetainNonConfigurationChildInstances() {
101         return mLocalActivityManager.dispatchRetainNonConfigurationInstance();
102     }
103 
getCurrentActivity()104     public Activity getCurrentActivity() {
105         return mLocalActivityManager.getCurrentActivity();
106     }
107 
getLocalActivityManager()108     public final LocalActivityManager getLocalActivityManager() {
109         return mLocalActivityManager;
110     }
111 
112     @Override
dispatchActivityResult(String who, int requestCode, int resultCode, Intent data, ComponentCaller caller, String reason)113     void dispatchActivityResult(String who, int requestCode, int resultCode,
114             Intent data, ComponentCaller caller, String reason) {
115         if (who != null) {
116             Activity act = mLocalActivityManager.getActivity(who);
117             /*
118             if (false) 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, caller, reason);
129     }
130 }
131 
132 
133