When fragment is detached from activity, getActivity() return null, so getActivity().getApplication() produce NPE. So we should check whether the fragment is attached to activity.
This commit is contained in:
parent
9e044b5449
commit
7ea02dcdae
1 changed files with 4 additions and 1 deletions
|
@ -18,8 +18,11 @@ public class BaseOsmAndFragment extends Fragment {
|
||||||
private IconsCache iconsCache;
|
private IconsCache iconsCache;
|
||||||
|
|
||||||
protected OsmandApplication getMyApplication() {
|
protected OsmandApplication getMyApplication() {
|
||||||
|
if (isAdded()) {
|
||||||
return (OsmandApplication) getActivity().getApplication();
|
return (OsmandApplication) getActivity().getApplication();
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
protected OsmandActionBarActivity getMyActivity() {
|
protected OsmandActionBarActivity getMyActivity() {
|
||||||
return (OsmandActionBarActivity) getActivity();
|
return (OsmandActionBarActivity) getActivity();
|
||||||
|
|
Loading…
Reference in a new issue