I am using the Google Map\'s Places API\'s AutoCompleteSearchFragment
in a Dialog
. The error that I am getting occurs when I launch the dialog, close i
I found the solution to the problem, for those that it may help later on.
In order to prevent the Activity
from thinking that there is more than one AutocompleteSearchFragment
with the same ID each time I open the Dialog
, I set a onDismissListener
for the Dialog
in order to remove the AutocompleteSearchFragment
:
The code:
alert.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
getSupportFragmentManager().beginTransaction().
remove((Fragment) autocompleteSupportFragment).commit();
}
});
What the code above does is when the Dialog
called alert
is dismissed, it uses the SupportFragmentManager
to remove that AutocompleteSearchFragment
.