I have a simple layout which contains LaunchFragment
. Pressing a button in LaunchFragment
replaces it with a MapFragment
as follows:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map_test);
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction().replace(R.id.content_view, new LaunchFragment()).commit();
}
@Override
public void onTriggerReplace(int id) {
switch (id){
case R.id.btn_replace_google:
launchGoogleMapsFrag();
break;
}
}
private void launchGoogleMapsFrag() {
FragmentManager fm = getFragmentManager();
fm.beginTransaction().replace(R.id.content_view, MapFragment.newInstance()).commit();
}
Note: onTriggerReplace(int)
is invoked by the launch fragment. The code pasted above resides in the activity which is hosting the fragments.
The problem is that the replace causes the following warning:
01-10 01:12:18.575 27820-27820/com.test.mapsprototype I/Choreographer﹕ Skipped 83 frames! The application may be doing too much work on its main thread.
The delay is quite noticeable. Is there any way around it?
What I already know:
- Starting a new activity (which will have the map fragment) from launch fragment does not show this warning however my requirements prevent me from doing so.
Update (Requirement(s)): The only requirement I need to satisfy is have it integrate into a bigger application which already does the fragment replace for me as long as I provide it with the fragment so I don't have the option to launch another activity. All the other fragments seem to work fine but the map fragment causes the frame skipping.