Google Places AutoComplete + Android Fragment <p>I am a beginner on Android development and I came into a problem which I hope you can help me to solve. I'll keep it simple...i am trying to use Google Places autocompletion in a fragment...the app stops right from the beginning. My guess is the problem is when I use the method <code>rebuildGoogleApiClient()</code> and when I set up the <code>PlaceAutocompleteAdapter</code> after that. Here is my code:</p> <p>(<code>ActivityMap.java</code> - sets up the GoogleMap and creates the fragment)</p> <pre><code> public class ActivityMap extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_map); (...) } //creates fragment private void selectItem(int position) { (...) MyFragment fragment = new MyFragment(); FragmentManager fragmentManager = this.getSupportFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(R.id.content_frame, fragment); fragmentTransaction.commit(); } } </code></pre> <p>(<code>MyFragment.java</code> - contains the <code>AutoCompleteTextView</code>)</p> <pre><code> public class MyFragment extends Fragment implements GoogleApiClient.OnConnectionFailedListener, GoogleApiClient.ConnectionCallbacks { View rootView; AutoCompleteTextView from; GoogleApiClient mGoogleApiClient; PlaceAutocompleteAdapter mAdapter; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.myFragment, container, false); if (mGoogleApiClient == null) { rebuildGoogleApiClient(); } from = (AutoCompleteTextView) rootView.findViewById(R.id.autoCompleteFrom); (...) mAdapter = new PlaceAutocompleteAdapter(this.getActivity(), android.R.layout.simple_list_item_1, null, null); from.setAdapter(mAdapter); return rootView; } private void rebuildGoogleApiClient() { mGoogleApiClient = new GoogleApiClient.Builder(this.getActivity()).enableAutoManage(this.getActivity(), 0 /* clientId */, this).addConnectionCallbacks(this).addApi(Places.GEO_DATA_API).build(); } } </code></pre> <p>(<code>PlaceAutocompleteAdapter</code> - Adapter that handles Autocomplete requests from the Places Geo Data API )</p> <pre><code> public class PlaceAutocompleteAdapter extends ArrayAdapter&lt;PlaceAutocompleteAdapter.PlaceAutocomplete&gt; implements Filterable { LatLngBounds mBounds; AutocompleteFilter mPlaceFilter; //constructor public PlaceAutocompleteAdapter(Context context, int resource,LatLngBounds bounds, AutocompleteFilter filter) { super(context, resource); mBounds = bounds; mPlaceFilter = filter; } } </code></pre> <p>(<code>activity_map.xml</code>)</p> <pre><code> &lt;LinearLayout android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;FrameLayout android:id="@+id/content_frame" android:layout_width="match_parent" android:layout_height="match_parent"&gt; &lt;fragment android:id="@+id/map" android:name="com.google.android.gms.maps.SupportMapFragment" android:layout_width="match_parent" android:layout_height="match_parent" /&gt; &lt;/FrameLayout&gt; &lt;/LinearLayout&gt; </code></pre> <p>(my_fragment.xml)</p> <pre><code> &lt;RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" &gt; &lt;TextView android:id="@+id/from" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="From" /&gt; &lt;AutoCompleteTextView android:id="@+id/autoCompleteFrom" android:layout_width="match_parent" android:layout_height="wrap_content" android:completionThreshold="2" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Let me know if you need some extra info or extra code and thank you in advance.</p> <p>Here are the logs:</p> <pre><code> 05-07 16:52:55.840: E/AndroidRuntime(2664): FATAL EXCEPTION: main 05-07 16:52:55.840: E/AndroidRuntime(2664): Process: com.example.blueHatCoder.myapplication1, PID: 2664 05-07 16:52:55.840: E/AndroidRuntime(2664): java.lang.IllegalStateException: Recursive entry to executePendingTransactions 05-07 16:52:55.840: E/AndroidRuntime(2664): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1473) 05-07 16:52:55.840: E/AndroidRuntime(2664): at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:490) 05-07 16:52:55.840: E/AndroidRuntime(2664): at com.google.android.gms.common.api.zzh.zza(Unknown Source) 05-07 16:52:55.840: E/AndroidRuntime(2664): at com.google.android.gms.common.api.GoogleApiClient$Builder.zzhZ(Unknown Source) 05-07 16:52:55.840: E/AndroidRuntime(2664): at com.google.android.gms.common.api.GoogleApiClient$Builder.build(Unknown Source) 05-07 16:52:55.840: E/AndroidRuntime(2664): at com.example.blueHatCoder.myapplication1.MyFragment.rebuildGoogleApiClient(MyFragment.java:155) 05-07 16:52:55.840: E/AndroidRuntime(2664): at com.example.blueHatCoder.myapplication1.MyFragment.onCreateView(MyFragment.java:51) 05-07 16:52:55.840: E/AndroidRuntime(2664): at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789) 05-07 16:52:55.840: E/AndroidRuntime(2664): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955) 05-07 16:52:55.840: E/AndroidRuntime(2664): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138) 05-07 16:52:55.840: E/AndroidRuntime(2664): at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740) 05-07 16:52:55.840: E/AndroidRuntime(2664): at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501) 05-07 16:52:55.840: E/AndroidRuntime(2664): at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:458) 05-07 16:52:55.840: E/AndroidRuntime(2664): at android.os.Handler.handleCallback(Handler.java:739) 05-07 16:52:55.840: E/AndroidRuntime(2664): at android.os.Handler.dispatchMessage(Handler.java:95) 05-07 16:52:55.840: E/AndroidRuntime(2664): at android.os.Looper.loop(Looper.java:135) 05-07 16:52:55.840: E/AndroidRuntime(2664): at android.app.ActivityThread.main(ActivityThread.java:5221) 05-07 16:52:55.840: E/AndroidRuntime(2664): at java.lang.reflect.Method.invoke(Native Method) 05-07 16:52:55.840: E/AndroidRuntime(2664): at java.lang.reflect.Method.invoke(Method.java:372) 05-07 16:52:55.840: E/AndroidRuntime(2664): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 05-07 16:52:55.840: E/AndroidRuntime(2664): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 05-07 16:52:55.865: W/ActivityManager(1222): Force finishing activity com.example.blueHatCoder.myapplication1/.ActivityMap </code></pre>