androidxamarin.androidgoogle-play-servicesgoogle-play-gamesachievements

ActivityNotFoundException when trying to display Google Play Achievements


I am developing an app with Xamarin Android and successfully managed to sign in to Google Play.

Now I am trying to display the list of achievements from my Main Activity.

I am following the official documentation for Java and this is the code I have so far in a helper class:

public static void ShowAchievementsList(Activity activity)
{
    PlayGames.GetAchievementsClient(activity)
        .GetAchievementsIntent()
        .AddOnSuccessListener(new AchievementListListener(activity));
}

// ...

public class AchievementListListener : Java.Lang.Object, IOnSuccessListener
{
    private Activity _activity;

    public AchievementListListener(Activity activity)
    {
        _activity = activity;
    }
    public void OnSuccess(Java.Lang.Object intentObject)
    {
        _activity.StartActivityForResult(intentObject.GetType(), 1234);
    }
}

But when it tries to execute the StartActivityForResult method it is getting the following error:

Android.Content.ActivityNotFoundException Message=Unable to find explicit activity class {com.example.myapp/android.content.Intent}; have you declared this activity in your AndroidManifest.xml?

How can I fix this exception?

What should I exactly add to the manifest?


Solution

  • Fixed by calling a different method overload.

    _activity.StartActivityForResult((Intent)intentObject, 1234);