关闭wifi后,不会显示GoogleMap v2

时间:2015-02-18 09:37:05

标签: android

我在我的应用程序中使用GoogleMap v2 API。当我进行全新安装并且我连接到wifi时,Google地图加载并在我的片段中显示正常。但是,如果我进行全新安装并且我没有连接到wifi网络,则地图永远不会显示。下面的代码在两种情况下执行完全相同,并且logcat中没有显示错误:

在我的onCreateView:

rootView = inflater.inflate(R.layout.map_fragment, container, false);
mMapFragment = new SupportMapFragment() {
    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
         super.onActivityCreated(savedInstanceState);
         Log.d("MAP", "on activity created");
         googleMap = mMapFragment.getMap();
         if (googleMap != null) {
              Log.d("MAP", "google map not null");
//                    initializeGoogleMap();
         } else {
              Log.d("MAP", "google map null");
         }
    }
};
getChildFragmentManager().beginTransaction().add(R.id.map, mMapFragment).commit();

wifi打开输出(地图显示):

D/MAP﹕ on activity created
D/MAP﹕ google map not null

wifi关闭输出(地图未显示):

D/MAP﹕ on activity created
D/MAP﹕ google map not null

为什么会这样?我该怎么做才能解决这个问题?此刻,我很难过。提前谢谢!

1 个答案:

答案 0 :(得分:2)

如果没有任何效果,那么您还可以检查是否限制了Google Play服务的背景数据。如果有,请尝试取消选中该限制,然后重试...有关如何使用" unrestrict"背景数据here

希望这会有所帮助......

相关问题