Closed adienthu closed 5 years ago
Same here, can't trigger lifecycle event on a MapView. Annotations are probably broken.
Add [Export] and it’ll work
[Lifecycle.Event.OnStart] [Export] public void onAppForegrounded() { Log.Debug(TAG, "App entered foreground state."); }
@ocjadan ty, but I still get
Java.Lang.IllegalArgumentException: invalid parameter type. Must be one and instanceof LifecycleOwner at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0 at Java.Interop.JniEnvironment+InstanceMethods.CallVoidMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x00069] in <09bf3e262b934ffab2ba01f9fc7fd54d>:0 at Android.Runtime.JNIEnv.CallVoidMethod (System.IntPtr jobject, System.IntPtr jmethod, Android.Runtime.JValue* parms) [0x0000e] in <25661073a35344a89f215a4cf81af37c>:0
when I try to add an Observer to a Owner
ReflectiveGenericLifecycleObserver.java
if (params.length > 0) { callType = CALL_TYPE_PROVIDER; if (!params[0].isAssignableFrom(LifecycleOwner.class)) { throw new IllegalArgumentException( "invalid parameter type. Must be one and instanceof LifecycleOwner"); } }
edit: I added LifecycleOwner as first parameter in Observer's callbacks and it's not crying about it anymore but the Android doc says:
Observer methods can receive zero or one argument. If used, the first argument must be of type LifecycleOwner. Methods annotated with ON_ANY can receive the second argument, which must be of type Lifecycle.Event.
We'll take a look at this but I suspect we haven't allowed for arguments as you seem to have found.
The code we're using really only does some trickery around emitting the correct java annotation. As long as you're using [Export]
I don't see why this shouldn't work to use the allowed zero or one argument as per the rules in the docs.
Xamarin.Android Version:
8.2.0.16 (Visual Studio Community)
Operating System & Version:
Mac OS X 10.13.1
Support Libraries Version:
27.0.2
Describe your Issue:
I'm unable to get the capture lifecycle events to detect application entering background or foreground. In the sample code below, the methods
onApplicationForegrounded
andonApplicationBackgrounded
are not invoked: