在我的應用程序,當用戶沒有登錄我用 - ActivityA當用戶是日誌中 - ActivityB 。我在用戶沒有登錄的時候添加了一些標記,並且當用戶是時,我從JSON獲得了點數。如何識別哪個活動「調用」片段?如何識別我的地圖(谷歌地圖API V2)片段,其中活性通話片段
片段
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(GoogleMap mMap) {
googleMap = mMap;
//when the user is not log in
for (int i = 0; i < result.size(); i++) {
MarkerOptions marker = new MarkerOptions().position(new LatLng(result.get(i).getLat(), result.get(i).getLng())).title(result.get(i).getTitle());
googleMap.addMarker(marker);
}
//add here code when user is log in
//show image of the point in dialog
googleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
Log.i("MARKER", marker.getPosition().toString());
showAlertDialog(marker);
}
});
}
});
}
我的想法是把一些布爾值,像userIsLogin然後檢查真/假,讓列表取決於布爾值。 有沒有更好的解決方案?
感謝