2016-04-27 44 views
0

我目前正在使用OSMdroid 5.1在Samsung Galaxy Tab E上开发一个应用程序。 我的问题在于我无法让指南针显示出来。我在互联网和OSMdroid源代码上搜索了几个小时,但我无法弄清楚。 我决定在我的个人手机(Samsung Galaxy S4)上进行测试,结果表明它在此设备上出现并完美工作。CompassOverlay的设备特定错误?

平板电脑上运行Android 5.1.1

电话是在Android 5.0.1

运行,我使用的是Android 2.1工作室

以下是所有指CompassOverlay代码。

@Override 
public void onResume() { 
    super.onResume(); 

    compassOverlay.enableCompass(); 
    myLocationOverlay.enableMyLocation(); 
    //mMyLocationOverlay.enableFollowLocation(); 
} 

@Override 
public void onPause() { 
    super.onPause(); 

    compassOverlay.disableCompass(); 
    this.myLocationOverlay.disableMyLocation(); 
    //this.myLocationOverlay.disableFollowLocation(); 
} 

private void mapEndConfig() { 
    this.osmv.setBuiltInZoomControls(true); 
    this.osmv.setMultiTouchControls(true); 

    osmv.getController().setZoom(11); 
    double lon = -64.5996; //-74.15702819824206; //,45.6294 
    double lat = 45.6294; //40.64938745451832; 

    IGeoPoint point = new GeoPoint(lat, lon); // lat lon and not inverse 
    osmv.getController().setCenter(point); 

    myLocationOverlay = new MyLocationNewOverlay(this, osmv); 
    compassOverlay = new CompassOverlay(this, new InternalCompassOrientationProvider(this), this.osmv, mResourceProxy); 
    osmv.getOverlayManager().add(myLocationOverlay); 
    osmv.getOverlayManager().add(compassOverlay); 

    /*anotherOverlayItemArray = new ArrayList<OverlayItem>(); 
    anotherOverlayItemArray.add(new CompassOverlay()); 

    ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay 
      = new ItemizedIconOverlay<OverlayItem>(
      this, anotherOverlayItemArray, null); 
    this.mOsmv.getOverlays().add(anotherItemizedIconOverlay);*/ 



    /*myLocationOverlay.runOnFirstFix(new Runnable() { 
     public void run() { 
      osmv.getController().animateTo(myLocationOverlay.getMyLocation()); 
     } 
    });*/ 
} 

以前似乎没有人遇到类似这样的指南针,有没有人有解决方案?

回答

0

好吧,我发现了这个问题。这是因为三星Galaxy Tab E没有指南针的磁力计。

当OSMdroid没有检测到它,而不是提供错误或警告,它根本不显示它。