MapFragment中的getMapAsync不能应用于java.lang.Runnable

时间:2017-01-19 12:29:24

标签: android google-maps android-fragments android-asynctask android-mapview

我试图在AsyncTask中获取地图,在片段内的thismapFragment.getMapAsync(this);处提到错误

private class BackGroundTaskForUserProfile extends AsyncTask<String, Void, Void> {

 getActivity().runOnUiThread(new Runnable() {
                @Override
                public void run() {
 MapFragment mapFragment = (MapFragment) getActivity().getFragmentManager()
                            .findFragmentById(R.id.map);
                    mapFragment.getMapAsync(this);

1 个答案:

答案 0 :(得分:2)

mapFragment.getMapAsync(getContext());