I have the following problem. I have three fragments which are hosted in a TabHost. When I'm working with the app everything works fine. Now I like to end the app when the user hits the back button. Instead of terminating without errors I get the message Unfortunately App stopped. Then I said to myself something is wrong with the onDestroy() method of the FragmentActivity or with the onDestroyView method() of the Fragment. The problem is I cannot debug the point where the app crash. I get only the error:Fatal signal 11 (SIGSEGV). I then removed one by one each Fragment to identify which fragment causes the error. I could identify the fragment that I named BasicMapFragment. Something is wrong there.
The code:
public class BasicMapFragment extends SupportMapFragment implements LocationListener {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = super.onCreateView(inflater, container, savedInstanceState);
//removeAllMarkers();
//setupGps();
//setupMap();
//setupMarkersFromModel();
//registerListeners();
return view;
}
}
I commented out all my self written code to isolate the place where the error occurs.
@Override
public void onDestroy() {
Log.d("ch.xxx.fragment.BasiceMapFragment", "On destroy called");
super.onDestroy();
}
public void onDestroyView() {
Log.d("ch.xxx.fragment.BasiceMapFragment", "On destroy view called");
super.onDestroyView();
}
When I press the back button now the onDestroy() method of my FragmentActivity is first called like expected. Then the onDestroyView method is called on my BasicMapFragment class. At the end the onDestroy method is called - and then the application crash.
Here is my layout file:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.google.android.gms.maps.SupportMapFragment"/>
</FrameLayout>
Resume:
- Map is showed - I can work with the app.
- When I leave out the BasicMapFragment the app finish without error.
- When I add the BasicMapFragment the app returns an error when I press the back button
Is there something that I have forgot to implement? Have somebody had the same trouble?