common.apiexception.c:不在主线程上

时间:2019-01-12 10:56:32

标签: android google-maps

当我尝试将标记添加到GoogleMaps地图时出现此错误:

   com.google.maps.api.android.lib6.common.apiexception.c: Not on the main thread

该如何解决?
-这是产生标记的类:

   public class MobSpawner {
public LatLng posPlayer=new LatLng(1,1);
Randomizzatore valori=new Randomizzatore();


public void setPosPlayer(LatLng posPlayer) {
    this.posPlayer = posPlayer;
}
public void spawna(){
    Marker mPosMostro;
    LatLng posMostro=new LatLng(valori.randomCoord(posPlayer.latitude),valori.randomCoord(posPlayer.longitude));
    mPosMostro = MapsActivity.mMap.addMarker(new MarkerOptions().position(posMostro).title("mostroo"));
}}

0 个答案:

没有答案