Starting activity UI called by a DepedancyService not working?

in the forms that is under a button
DependencyService.Get().FacebookLogin();

above the namespace of main activity
[assembly: Dependency(typeof(IFacebookLogin))]//my custom dependacy

the main activity uses the IFacebookLogin
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity , IFacebookLogin{}

in the OnCreate of main activity
Xamarin.Forms.DependencyService.Register();

//called by DependencyService.Get
void IFacebookLogin.FacebookLogin()
{
StartActivity(typeof(Activity2));//some activity i want to call // ERROR HERE
}

Java.Lang.NullPointerException: Attempt to invoke virtual method 'android.app.ActivityThread$ApplicationThread android.app.ActivityThread.getApplicationThread()' on a null object reference

Best Answer

  • caricari US
    Accepted Answer

    OK solved
    Forms.Context.StartActivity(typeof(Activity2))

Answers

  • caricari USMember
    Accepted Answer

    OK solved
    Forms.Context.StartActivity(typeof(Activity2))

Sign In or Register to comment.