Closed xyfoo closed 5 years ago
In C# method/function signature does not include return type.
Have you ever tried to "overload" method based on return type? This is no-no (nyet-nyet) in C#. These are some language idiomatic diffs Binders (people that bind libraries) face. So, pasting links for AndroidX docs is nice, but will not guarantee that workaround will be found.
So, C# bindings return base class LiveData
as a LCD (Least Common Denominator). I agree I could return Java.Lang.Object
, but you would hate me even more.
Please, check if you can find workaround.
Closing this one soon.
Try using .JavaCast<T>
in this case:
var workInfos = myLiveData.Value.JavaCast<List<WorkInfo>>();
Try using
.JavaCast<T>
in this case:var workInfos = myLiveData.Value.JavaCast<List<WorkInfo>>();
Hi! The code caused the following exception. How to deal with it?
The type 'System.Collections.Generic.IList<AndroidX.Work.WorkInfo>' cannot be used as type parameter 'TResult' in the generic type or method 'Extensions.JavaCast<TResult>(IJavaObject)'. There is no implicit reference conversion from 'System.Collections.Generic.IList<AndroidX.Work.WorkInfo>' to 'Android.Runtime.IJavaObject'.
Package
Xamarin.Android.Arch.Work.Runtime 1.0.0
Issue
AndroidX.Work.WorkManager.GetWorkInfosByTagLiveData
method only returnLiveData
instead ofLiveData<List<WorkInfo>
, as stated in the AndroidX's documentation for the method.Current method's metadata as displayed in Visual Studio 2017.
By not having a typed LiveData object, we would not be able to retrieve the value of the LiveData as below:
WorkManager methods with the same issue
Version