Android AccountPicker - No Activity found to handle intent

In onCreate method of LoginActivity,

button.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {

        Intent intent = AccountPicker.newChooseAccountIntent(null, null, new String[]{"com.google"},
                false, null, null, null, null);
        startActivityForResult(intent, SOME_REQUEST_CODE);
    }
});

I also have the ff method:

protected void onActivityResult(final int requestCode, final int resultCode,
        final Intent data) {
    if (requestCode == SOME_REQUEST_CODE && resultCode == RESULT_OK) {
        ...
    }
}

In AndroidManifest:

<activity
    android:name="LoginActivity"
    android:label="@string/title_activity_login" >
</activity>

When testing the app in my Android Device running 2.3.6, I encountered the error below:

ActivityNotFound No Activity found to handle intent com.google.android.gms.common.account.CHOOSE_ACCOUNT

How to fix it?

Answers


As you are using a Google Play Services component (the AccountPicker), you need to ensure that Google Play Services exists and is up to date on the users device before calling methods that use the service as explained in the setup guide.


Does the device have Google Play Services installed ? Also check out the version of Google Play Services library you are using in your code. You need to use the Froyo version.

You can check the availability as follows:

int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
                if (status != ConnectionResult.SUCCESS)
                {
                        Log.e(App.TAG, String.valueOf(status));
                        Toast.makeText(this, getString(R.string.gps_missing), Toast.LENGTH_LONG).show();
                        finish();
                        return;
                }

http://android-developers.blogspot.in/2013/10/google-play-services-40.html

Update: Also revisit how you obtain the intent. This is how do I in my app:

  try
                        {

                                startActivityForResult(credential.newChooseAccountIntent(), REQUEST_ACCOUNT_PICKER);
                        }
                        catch (ActivityNotFoundException e)
                        {

                                Toast.makeText(this, getString(R.string.gps_missing), Toast.LENGTH_LONG).show();

                                return;
                        }

Full source: https://github.com/madhur/GAnalytics/blob/develop/src/in/co/madhur/ganalyticsdashclock/MainActivity.java


Need Your Help

Asynctask onpostexecute is not updating views if the screen is rotated while doinbackground is excuted

java android android-asynctask screen-orientation

I had a simple program where i need to update the list and text based on the server response ...

How do I update my custom extension in Visual Studio without requiring it to be uninstalled first?

visual-studio visual-studio-extensions

I have created a custom Visual Studio extension and have deployed via a internal Extension Gallery. When I make an update to my extension, it correctly shows up in Visual Studio Extensions and Upda...