如何在Monogame中使用Xamarin.Auth?

时间:2014-03-01 17:04:28

标签: android facebook xamarin monogame xamarin.auth

我使用monogame开发跨平台游戏。对于android我有一个活动:

[Activity (Label = "GameName", 
    MainLauncher = true,
    Icon = "@drawable/icon",
    Theme = "@style/Theme.Splash",
    AlwaysRetainTaskState = true,
    LaunchMode = Android.Content.PM.LaunchMode.SingleInstance,
    ConfigurationChanges = Android.Content.PM.ConfigChanges.Orientation |
    Android.Content.PM.ConfigChanges.KeyboardHidden |
    Android.Content.PM.ConfigChanges.Keyboard, 
    ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait)]
public class Activity1 : AndroidGameActivity
{
    protected override void OnCreate (Bundle bundle)
    {
        base.OnCreate (bundle);         
        Game1.Activity = this;
        var _game = new Game1 ();
        SetContentView (_game.Window);
        _game.Run ();
    }
}

我还想使用Xamarin.Auth进行Facebook整合。 所以,我接着在onButtonTap做下一步:

var auth = new OAuth2Authenticator (
    clientId: "here_is_my_facebookApp_id",
    scope: "",
    authorizeUrl: new Uri ("https://m.facebook.com/dialog/oauth/"),
    redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html"));

auth.AllowCancel = true;
auth.Completed += (s, ee) => {
                                 // some code, does not matter what
                             };

var intent = _auth.GetUI (activity);
activity.StartActivity (intent);

活动是我的Activity1。 结果我在onButtonTap之后有空页面。 我在其他android项目中使用了相同的代码(没有monogame),它工作正常。但是如果我将它与monogame项目一起使用,那么结果就是一个空页面。

任何人都可以帮助它发挥作用吗?

0 个答案:

没有答案