Hi,
I have a portable Project and im trying to launch an Android Activity out of the Android Project and put it into the shared Project but I always get an unhandled exception.
In my Portable Project i have an Interface IOAuth2 and a ContentPage:
namespace Test.Services
{ public interface IOAuth2
{
void Login(bool allowCancel);
}
}
namespace Test.Pages
{
public partial class LogIn : ContentPage
{
public LogIn{
InitializeComponent();
DependencyService.Get<IOAuth2>().Login(true);
}
}
}
And in the Android Project I have this:
[assembly: Xamarin.Forms.Dependency(typeof(Test.Droid.Services.OAuth2))]
`namespace Test.Droid.Services
{
[Activity(Label = "Test.Droid.Services")]
public class OAuth2 : Activity , IOAuth2
{
private OAuth2Authenticator _auth;
public void Login(bool allowCancel)
{
_auth = new OAuth2Authenticator(
clientId:".......apps.googleusercontent.com",
//clientSecret: "......",
scope: "https://www.googleapis.com/auth/userinfo.email",
authorizeUrl: new Uri("https://accounts.google.com/o/oauth2/auth"),
redirectUrl: new Uri("http://localhost:8080/") //new Uri("urn:ietf:wg:oauth:2.0:oob")
);
_auth.AllowCancel = allowCancel;
_auth.Completed += (sender, ee) =>
{
if (!ee.IsAuthenticated)
{
return;
}
};
var intent = _auth.GetUI(this);
StartActivity(intent);}}`
I always get an unhanlded exception in this line var intent = _auth.GetUI(this);
Can anyone help me?
Thank you very much!!