通过在平板电脑中使用broadcastreceiver,当前位置在android中不起作用

通过在平板电脑中使用broadcastreceiver,当前位置在android中不起作用,android,android-fragments,broadcastreceiver,currentlocation,Android,Android Fragments,Broadcastreceiver,Currentlocation,我使用broadcastreceiver获取应用程序中的当前位置。它在我的手机中运行良好(返回当前位置值)。但是,当我谈到平板电脑时,它返回零值。对于我的标签版本,我使用的是片段概念。 这是我的广播接收机代码: public class LocationBroadcastReceiver extends BroadcastReceiver{ private static LocationInfo M_USER_LOCATION_INFO; @Override publi

我使用broadcastreceiver获取应用程序中的当前位置。它在我的手机中运行良好(返回当前位置值)。但是,当我谈到平板电脑时,它返回零值。对于我的标签版本,我使用的是片段概念。 这是我的广播接收机代码:

public class LocationBroadcastReceiver extends BroadcastReceiver{

    private static LocationInfo M_USER_LOCATION_INFO;
    @Override
    public void onReceive(Context context, Intent intent) {
        LocationInfo locationInfo = (LocationInfo) intent.getSerializableExtra(LocationLibraryConstants.LOCATION_BROADCAST_EXTRA_LOCATIONINFO);     
        refreshLocationIfChanged(locationInfo, context);
    }

    public static void refreshLocationIfChanged(LocationInfo locationInfo, Context context){
        if(locationInfo == null){
            locationInfo = new LocationInfo(context);
        } else{
            locationInfo.refresh(context);
        }
        if (locationInfo.anyLocationDataReceived()) {
            M_USER_LOCATION_INFO = locationInfo;
        }else{
            LocationLibrary.forceLocationUpdate(context);
        }       
    }

    public static Location getCurrentLocation(){    
        Location location = new Location("currentLocation");
        if(M_USER_LOCATION_INFO != null) {
            location.setLatitude(M_USER_LOCATION_INFO.lastLat);
            location.setLongitude(M_USER_LOCATION_INFO.lastLong);
        }   
        return location;
    }
}
为什么此代码不能在选项卡中工作。碎片有什么问题吗


有什么解决方案吗?

您注册了哪种广播服务?也许你的平板电脑不像手机那样播放服务;在我的课堂上,如何检查我的平板电脑是否有广播服务??