i am traing to make an offline map with mapsforge i flowd the example on https://github.com/mapsforge/mapsforge/blob/master/mapsforge-samples-android/src/main/java/org/mapsforge/samples/android/GettingStarted.java the first time it worked but i tried to add a gps location to that code but the map doesn't apeer now end i get
DatabaseRenderer: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.FileInputStream android.app.Application.openFileInput(java.lang.String)' on a null object reference
public class map extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
Drawable myLocationMarker = this.getResources().getDrawable(R.drawable.person);
// final MapViewPosition mapViewPosition = this.mapView.getModel().mapViewPosition;
try {
mapView = new MapView(this);
setContentView(mapView);
mapView.setClickable(true);
mapView.getMapScaleBar().setVisible(true);
mapView.setBuiltInZoomControls(true);
TileCache tileCache = AndroidUtil.createTileCache(map.this, "mapcache",
mapView.getModel().displayModel.getTileSize(), 1f,
mapView.getModel().frameBufferModel.getOverdrawFactor());
File file = new File("/sdcard/download/","centre.map");
MapDataStore mapDataStore = new MapFile(file);
TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, mapDataStore,
mapView.getModel().mapViewPosition, AndroidGraphicFactory.INSTANCE);
tileRendererLayer.setXmlRenderTheme(InternalRenderTheme.DEFAULT);
mapView.getLayerManager().getLayers().add(tileRendererLayer);
mapView.setZoomLevel((byte) 10);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
protected void onDestroy() {
mapView.destroyAll();
AndroidGraphicFactory.clearResourceMemoryCache();
super.onDestroy();
}
}
i don't understand the problem
thank you very match for your help i fond the cause of the problem i have forgotten to put
AndroidGraphicFactory.createInstance(getApplication());