Bug 57845 - Droid project can no longer case java object collection to JavaList - IllegalCastException
Summary: Droid project can no longer case java object collection to JavaList - Illegal...
Status: RESOLVED NORESPONSE
Alias: None
Product: Android
Classification: Xamarin
Component: General ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
Depends on:
Blocks:
 
Reported: 2017-06-28 19:21 UTC by Clint
Modified: 2017-08-21 21:28 UTC (History)
4 users (show)

Tags: 15.2R
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED NORESPONSE

Description Clint 2017-06-28 19:21:29 UTC
# Steps to reproduce
I'm using the NokiaHere API to get driving directions - but I image there are many other API's with similar callbacks.

# Expected behavior
This worked find before the update:
```
        #region  Geocode Listener
        public GeocodeListener Geocoder = new GeocodeListener();
        public class GeocodeListener : Object, IResultListener
        {//https://developer.here.com/mobile-sdks/documentation/android-starter/topics/geocoding.html
            public void OnCompleted(Object dataListLocations, ErrorCode p1)
            {// Street address supplied as request, collection of locations returned
                if (dataListLocations != null)
                {
                    JavaList locations = (JavaList)dataListLocations;
                    foreach (Location location in locations)
                    {
                        GeoCoordinate geo = location.Coordinate;
                        GpsPoint pt = new GpsPoint((decimal)geo.Latitude, (decimal)geo.Longitude);
                        RaiseRequestedCoordinateReceived(pt);
                        break;
                    }

                    ////var locations =  ((ArrayList) dataListLocations).ToEnumerable<Location>();
                    //if (locations.Any())
                    //{
                    //    GeoCoordinate geo = locations[0].Coordinate;
                    //    GpsPoint pt = new GpsPoint((decimal)geo.Latitude,(decimal)geo.Longitude);
                    //    RaiseRequestedCoordinateReceived(pt);
                    //}
                }
            }
            #region RequestedCoordinateReceived (Event) 
            public event EventHandler<GpsPoint> RequestedCoordinateReceived;
            public void RaiseRequestedCoordinateReceived(GpsPoint e)
            {
                EventHandler<GpsPoint> handler = RequestedCoordinateReceived;
                handler?.Invoke(this, e);
            }
            #endregion RequestedCoordinateReceived (Event)
        }
```

# Actual behavior
Now this line
`                    JavaList locations = (JavaList)dataListLocations;

# Supplemental info (logs, images, videos)


# Test environment (full version information)
	Win10Pro, VS2015Enterprise.  Xamarin.Forms solution
Comment 1 Jon Douglas [MSFT] 2017-07-05 17:00:49 UTC
Hi Clint,

Can you please provide a sample project that demonstrates this not working? It seems like this implicit cast isn't enough. You should instead try using JavaCast:

https://developer.xamarin.com/api/member/Android.Runtime.Extensions.JavaCast%7BTResult%7D/p/Android.Runtime.IJavaObject/

Either way, we will want a sample project that demonstrates this behavior so we can confirm it!

Thank you!
Comment 2 Jon Douglas [MSFT] 2017-08-21 21:28:10 UTC
Because we have not received a reply to our request for more information we are closing this issue. If you are still encountering this issue, please reopen the ticket with the requested information. Thanks!