I'm current using OSMdroid for offline maps rendering. Although there are some issues with tile loading every now and then for offline maps in osmdroid, I'm fine with it. But in my android app, I see when I test my map by just zooming in and zooming out multiple times, my app responds very slowly gradually over the time. I'm not sure what exactly might be the problem. Is this the issue with OSMdroid or my app, i'm unable to find out.
I have a fragment class which loads the mapoffline activity.
public class MapActivityFragment extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.map_view, container, false);
/*Create my offline MapView*/
oMapViewOffline = new MapViewOffline(mapView);
oMapViewOffline.run();
return rootView;
}
In my MapViewOffline.java
public void run(){
/*Get custom Tile data*/
MapTilerCustomDataSource myNewXYTileSource = new MapTilerCustomDataSource();
myNewXYTileSource.isSourceTMS = true;
mMapViewOSM.setTileSource(myNewXYTileSource);
mMapViewOSM.setUseDataConnection(false);
}
My MapTilerCustomDataSource is based on: OSMdroid : How to load offline map from zip archive - MapTileFileArchiveProvider
The biggest deal is not just loading of my offline maps, I'm running a expensive AsyncTask as well.
What it does is read data from server and draws markers accordingly on mapview. This again is degrading my performance.
@Override
protected Void doInBackground(Void... arg0) {
while(true){
Shadow = new CustomOverlay(getApplicationContext());
Shadow.getData();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
publishProgress();
mCount++;
}
}
@Override
protected void onProgressUpdate(Void... progress){
Shadow.runDrawing();
listOfSensorOverlays.add(Shadow);
mapView.invalidate();
}
How can I make my android app perform better? What might be the reasons that is causing the degrade in performance; Is it the osmdroid or the Async Task?