I have a layout with an embedded map fragment that has a default address marked each time. When the user clicks on the marker, two buttons pop up by default to send the user out to the google maps app either as a static request or as a directions request. These buttons seem to be there by default on Maps SDK (right next to the zoom in/out keys).
The problem arises when I run my app on an Android Go device that has Maps Lite installed instead of the regular version of Google Maps. In that case, the button to send the user to the external app seems to be searching for the normal google apps package and upon not finding it, displays a toast with the following warning: “Google maps is not installed or is disabled”.
Is there a way to change that default behaviour and have the button open Maps Lite instead? I have already added my own click listener in order to manually send the user out to the appropriate app using the relevant package. If I can’t change the Maps’ behaviour, is there a way to prevent those two buttons from showing altogether and allow my own click listener to navigate the user accordingly?
Edit regarding strikethrough: I did find that I can prevent the buttons from showing with the following line:
googleMap.getUiSettings().setMapToolbarEnabled(false);
The original question still stands though.
The layout of my activity is a simple Constraint layout that includes the map fragment:
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!-- Other textViews -->
<fragment
android:id="@+id/event_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="0dp"
android:layout_height="150dp"
android:layout_marginTop="24dp"
app:layout_constraintEnd_toEndOf="@id/event_title"
app:layout_constraintStart_toStartOf="@id/details_header"
app:layout_constraintTop_toBottomOf="@id/event_description" />
</androidx.constraintlayout.widget.ConstraintLayout>
My activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_event);
mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.event_map);
if (mapFragment != null) {
mapFragment.getMapAsync(this);
}
//...
@Override
public void onMapReady(GoogleMap googleMap) {
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
googleMap.getUiSettings().setZoomControlsEnabled(true);
if (hasMap) {
LatLng location;
location = new LatLng(coordinates[0], coordinates[1]);
if (location != null) {
googleMap.addMarker(new MarkerOptions().position(location).title(eventsTitle));
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(location, 14.0f));
}
}
}
}