placesautocomplete result code = 2
<p>I am trying to implement google Places APIs (Places Autocomplete) by creating an intent through intentBuilder. My app is successfully getting an intent with a button click but unable to search a place.</p>

<p>On overriding onActivityResult, it's getting resultCode = 2 instead of RESULT_SUCCESS, RESULT_ERROR or RESULT_CANCELLED and gets back to MainActivity.</p>

<p>I took reference from <a href="https://developers.google.com/places/android-api/autocomplete" rel="nofollow">https://developers.google.com/places/android-api/autocomplete</a>
and added a dependency</p>

<pre><code>compile 'com.google.android.gms:play-services-places:9.2.0' 
</code></pre>

<p>Here is my code</p>

<pre><code>@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == PLACE_AUTOCOMPLETE_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            Place place = PlaceAutocomplete.getPlace(this, data);
            Log.i(TAG, "Place: " + place.getAddress());
        } else if (resultCode == PlaceAutocomplete.RESULT_ERROR) {
            Status status = PlaceAutocomplete.getStatus(this, data);
            // TODO: Handle the error.
            Log.i(TAG, status.getStatusMessage());

        } else if (resultCode == RESULT_CANCELED) {
            Log.i("message", "the user cancelled the operation" );            }
    }
}
</code></pre>

<p>I need some assistance, please help. </p>