dimanche 20 juin 2021

EventBus Xamaring. Custom method of activity not found using reflection

I've added EventBus as a binding library in my Xamarin Android project. I can compile without errors but when I'm trying to register, I get the following error:

enter image description here

Here is the code for the activity

[Activity(Icon = "@mipmap/ic_launcher"]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        Forms.Init(this, savedInstanceState);
        Xamarin.Essentials.Platform.Init(this, savedInstanceState);
        CrossCurrentActivity.Current.Init(this, savedInstanceState);
        LoadApplication(new App());
        

        EventBus.Default.Register(this);
    }

    protected override void OnDestroy()
    {
        base.OnDestroy();
        EventBus.Default.Unregister(this);
    }

    [Subscribe]
    public void onEvent(DeviceConnectionEvent my_event)
    {
        throw new NotImplementedException();
    }

    protected override void OnActivityResult(int requestCode, Result resultVal, Intent data)
    {

        if (requestCode == 1)
        {
            wifiManagerInstance.onNetworkDataReceived();
        }

        base.OnActivityResult(requestCode, resultVal, data);

    }
}

It looks like my method is not being detected when eventbus uses reflection

methods = findState.clazz.getDeclaredMethods();

Other methods of the activity are detected as can be seen in the following picture.

enter image description here

Is there anything I can do?

Thanks in advance.





Aucun commentaire:

Enregistrer un commentaire