我使用monogame开发跨平台游戏。对于 android,我有一个 Activity:
[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);
活动是我的活动1。结果我在 onButtonTap 之后有空页面。我在其他android项目(没有monogame)中使用了相同的代码,它工作正常。但是,如果我将它与 monogame 项目一起使用,则结果是一个空页面。
任何人都可以帮助使其工作吗?