我正在使用Setlocationmanually活动来启动getlocation活动,这是默认的地图活动。但是发生的事情是mapactivity开始半秒钟,然后关闭,并且不允许我在地图上选择位置。 我正在使用15.0.0版本的所有gms:play-services依赖项。
我已经尝试了12,14,16版本的依赖关系
Setlocationmanually activity
public class Setlocationmanually extends AppCompatActivity {
TextView setlocation;
int PLACE = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setlocationmanually);
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_
BACKGROUNDS);
window.setStatusBarColor(Color.parseColor("#E4C206"));
setlocation = findViewById(R.id.setlocation);
}
@Override
protected void onActivityResult(int requestCode, int resultCode,
@Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
}
public void OnClick(View view)
{
PlacePicker.IntentBuilder builder =new PlacePicker.IntentBuilder();
try{
startActivityForResult(builder.build(this),PLACE);
} catch (GooglePlayServicesNotAvailableException e) {
e.printStackTrace();
} catch (GooglePlayServicesRepairableException e) {
e.printStackTrace();
}
}
}
Mapactivity(getlocation)
公共类getlocation扩展FragmentActivity实现OnMapReadyCallback {
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_getlocation);
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override public void onMapReady(GoogleMap googleMap){ mMap = googleMap;
// Add a marker in Sydney and move the camera
LatLng sydney = new LatLng(-34, 151);
mMap.addMarker(new MarkerOptions().position(sydney).title("Marker in Sydney"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney));
}
}
我想在地图上选择一个位置,然后手动在Setlocation活动中显示它,但是地图意外关闭。