I have a map and I add a marker on it when firebase massage received. sometimes, when I turn off my screen and then turn it on, i can't see my marker.
i have the following code in onResume:
if (situation_ == 3) {
if (marker == null){
Log.i("Logit", "is null");
}else{
Log.i("Logit", String.valueOf(marker.isVisible()));
}
if (marker == null || !marker.isVisible()) {
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
String Lat = pref.read_pref_info("usera");
String Lng = pref.read_pref_info("userb");
marker_op = new MarkerOptions().position(new LatLng(Double.valueOf(Lat), Double.valueOf(Lng)))
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.marker));
try {
Marker = mMap.addMarker(marker_op);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}, 2000);
}
so I can see in Logs that marker is not null and marker.isVisible returns true. but i can't see any marker on map and it doesn't go in this if line:
if (marker == null || !marker.isVisible()) {
From documentation.
public boolean isVisible ()
Gets the visibility setting of this marker. Note that this does not indicate whether the marker is within the screen's viewport. It indicates whether the marker will be drawn if it is contained in the screen's viewport.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments