简体   繁体   中英

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?

Fixed by calling a different method overload.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM