I have this code:
MainActivity:
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.
Is the above a right way to get child activity? If not, what is the best way to get child activity in this case?
There’s a LocalActivityManager#getActivity(String id) method available. Just use the same id you used to start the Activity.