How to get child activity in activity group?


I have this code:


public class MainActivity extends ActivityGroup

In MainActivity, I use this to start an activity and get its handle:

final LocalActivityManager manager = getLocalActivityManager(); final Intent i = new Intent(MainActivity.this, SearchActivity.class); final Window w = manager.startActivity("SearchActivity", i); Activity activity = (Activity) w.getContext();

The reason for this usage is that I want to minimize the responsibilities of MainActivity. SearchActivity will handle its own event.

<strong>Is the above a right way to get child activity? If not, what is the best way to get child activity in this case?</strong>


There's a <a href="http://developer.android.com/reference/android/app/LocalActivityManager.html#getActivity%28java.lang.String%29" rel="nofollow">LocalActivityManager#getActivity(String id)</a> method available. Just use the same id you used to start the Activity.


I hope it may help. it's my own experience that if you use Activity group then always try to open new activity from the activity group. i.e always open new activity from the group activity. if you open it from child activity it creates number of problem. one is window manager bad token exception.

to open new activity from group here is code: i hope it help you:

View view = getLocalActivityManager() .startActivity("ReferenceName",intent_to_start_activity .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) .getDecorView(); Your_group_cativity.this.setContentView(view);


  • Accessing web services uniformly
  • How to get child activity in activity group?
  • Why does starting a new Android activity in Kotlin require a Java class? [duplicate]
  • Get Variable from another Activity (Android Studio)
  • unit test via output sanity checks
  • Interface observer pattern: null object reference
  • HTML5 canvas drawImage not working on first click
  • Get byte[] from
  • How to Filter ListAdapter using getFilter() within a fragment
  • IndexSizeError on drawImage on IE and Edge
  • How to create an HtmlHelper extension method that will bind an IEnumerable to a table
  • How to move again MainActivity after sending the mail?
  • Android - Call default browser with and redirect to a designated url
  • Receive custom intent without activity restart
  • Android NFC read Tags issue. Activity starts each time on data received
  • How to change placeholder text in an autocomplete activity of android google place?
  • Send data from edittext to listview
  • EditText is covered by Keyboard
  • Splash Screen will not display
  • How can go in last activity with resume button?
  • URLConnection doesn't work since API 10 and higher?
  • Android Google Maps API v2 start navigation
  • Android application: how to use the camera and grab the image bytes?
  • How to render a blob on a canvas element?
  • Unity3D & Android: Difference between “UnityMain” and “main” threads?
  • Dialing with Intent.ACTION_CALL stopps at # in phone number
  • Disabling Alt-F4 on a Win Forms NotifyIcon
  • AngularJs get employee from factory
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • unknown Exception android