<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Unable to cast LocationDataSource.Location to NmeaDataSource.Location in ArcGIS Runtime SDK for Android Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/unable-to-cast-locationdatasource-location-to/m-p/593670#M4122</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;Thanks for the response.&amp;nbsp; My main goal here is to be able to get the number of satellites and X/Y coordinates without having multiple location providers.&amp;nbsp; Right now I am able to grab the ESRI Location when it changes here as per the LocationDisplay.LocationChangedListener and then populate X/Y location in the widget.&amp;nbsp; However I end up getting number of satellites from Android location as you can see in the code below from the Android locationManager last known location.&amp;nbsp; I would prefer to get number of satellites from the same source via LocationDisplay.&amp;nbsp; Here is what I am currently doing and it does work just fine...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;lListener &lt;/SPAN&gt;= &lt;SPAN style="color: #000080; font-weight: bold;"&gt;new &lt;/SPAN&gt;LocationDisplay.LocationChangedListener() {&lt;BR /&gt; &lt;SPAN style="color: #808000;"&gt;@Override&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #808000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public void &lt;/SPAN&gt;onLocationChanged(LocationDisplay.LocationChangedEvent locationChangedEvent) {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;              double &lt;/SPAN&gt;latitude = locationChangedEvent.getLocation().getPosition().getY();
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;              double &lt;/SPAN&gt;longitude = locationChangedEvent.getLocation().getPosition().getX();
&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Location androidLocation = &lt;SPAN style="color: #660e7a;"&gt;locationManager&lt;/SPAN&gt;.getLastKnownLocation(LocationManager.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;GPS_PROVIDER&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Integer sats = &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;androidLocation&lt;/SPAN&gt;.getExtras().getInt(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"satellites"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My thought process was that if I could cast this&amp;nbsp;within the LocationChangedListener..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;NmeaDataSource.Location loc = (NmeaDataSource.Location) locationChangedEvent.getSource().getLocation();&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That I could then&amp;nbsp;get the number of satellites as followed.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Integer sats = loc.getSatellites().size();&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/503074_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:30:05 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2021-12-12T01:30:05Z</dc:date>
    <item>
      <title>Unable to cast LocationDataSource.Location to NmeaDataSource.Location</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/unable-to-cast-locationdatasource-location-to/m-p/593668#M4120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;When I try to cast&amp;nbsp;LocationDataSource.Location to NmeaDataSource.Location I get the following error...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;java.lang.ClassCastException: com.esri.arcgisruntime.location.LocationDataSource$Location cannot be cast to com.esri.arcgisruntime.location.NmeaDataSource$Location&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am wondering why this does not work?&amp;nbsp; I am using 100.8 and the documentation seems to indicate casting should be possible...&lt;/P&gt;&lt;P&gt;&lt;A class="link-titled" href="https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/location/NmeaDataSource.Location.html" title="https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/location/NmeaDataSource.Location.html" rel="nofollow noopener noreferrer" target="_blank"&gt;NmeaDataSource.Location (ArcGIS Runtime SDK for Android 100.8.0)&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It states the following there...&lt;/P&gt;&lt;P&gt;---------------------------------------------------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;UL class="" style="color: #353833; background-color: #ffffff;"&gt;&lt;LI&gt;java.lang.Object&lt;/LI&gt;&lt;LI&gt;&lt;UL class="" style="margin: 0px 0px 0px 15px; padding: 1px 0px 0px 15px;"&gt;&lt;LI&gt;&lt;A href="https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/location/LocationDataSource.Location.html" style="color: #4a6782; text-decoration: none;" title="class in com.esri.arcgisruntime.location" rel="nofollow noopener noreferrer" target="_blank"&gt;com.esri.arcgisruntime.location.LocationDataSource.Location&lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;&lt;UL class="" style="margin: 0px 0px 0px 15px; padding: 1px 0px 0px 15px;"&gt;&lt;LI&gt;com.esri.arcgisruntime.location.NmeaDataSource.Location&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;DIV class="" style="color: #353833; background-color: #ffffff;"&gt;&lt;UL class="" style="margin: 10px 0px;"&gt;&lt;LI class="" style="margin-bottom: 15px;"&gt;&lt;DL&gt;&lt;DT style="color: #4e4e4e; font-weight: bold; font-size: 12px; margin: 10px 0px 0px;"&gt;Enclosing class:&lt;/DT&gt;&lt;DD style="font-size: 14px; margin: 5px 0px 10px;"&gt;&lt;A href="https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/location/NmeaDataSource.html" style="color: #4a6782; text-decoration: none;" title="class in com.esri.arcgisruntime.location" rel="nofollow noopener noreferrer" target="_blank"&gt;NmeaDataSource&lt;/A&gt;&lt;/DD&gt;&lt;/DL&gt;&lt;HR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;public static final class &lt;SPAN class="" style="font-weight: bold;"&gt;NmeaDataSource.Location&lt;/SPAN&gt;extends &lt;A href="https://developers.arcgis.com/android/latest/api-reference/reference/com/esri/arcgisruntime/location/LocationDataSource.Location.html" style="color: #4a6782; text-decoration: none;" title="class in com.esri.arcgisruntime.location" rel="nofollow noopener noreferrer" target="_blank"&gt;LocationDataSource.Location&lt;/A&gt;&lt;/PRE&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;---------------------------------------------------------------------------------------------------------------------------------------------------------------&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Below is the code that I am using&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;lListener &lt;/SPAN&gt;= &lt;SPAN style="color: #000080; font-weight: bold;"&gt;new &lt;/SPAN&gt;LocationDisplay.LocationChangedListener() {
   &lt;SPAN style="color: #808000;"&gt;@Override
&lt;/SPAN&gt;&lt;SPAN style="color: #808000;"&gt;   &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public void &lt;/SPAN&gt;onLocationChanged(LocationDisplay.LocationChangedEvent locationChangedEvent) {
      &lt;SPAN style="color: #000080; font-weight: bold;"&gt;try &lt;/SPAN&gt;{ &lt;SPAN style="color: #808080;"&gt;
&lt;/SPAN&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;          NmeaDataSource.Location mLocation = (NmeaDataSource.Location) locationChangedEvent.getSource().getLocation();&lt;/PRE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:30:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/unable-to-cast-locationdatasource-location-to/m-p/593668#M4120</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T01:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to cast LocationDataSource.Location to NmeaDataSource.Location</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/unable-to-cast-locationdatasource-location-to/m-p/593669#M4121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Arron,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to tell me exactly what you are trying to do here.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The NMEALocationDataSource class is for internal use only at the moment.&amp;nbsp; This will become a new item of functionality on a future release for high accuracy GPS devices.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you explain what you are trying to achieve, I can guide you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mark&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Aug 2020 09:57:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/unable-to-cast-locationdatasource-location-to/m-p/593669#M4121</guid>
      <dc:creator>MarkBaird</dc:creator>
      <dc:date>2020-08-11T09:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to cast LocationDataSource.Location to NmeaDataSource.Location</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/unable-to-cast-locationdatasource-location-to/m-p/593670#M4122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mark,&lt;/P&gt;&lt;P&gt;Thanks for the response.&amp;nbsp; My main goal here is to be able to get the number of satellites and X/Y coordinates without having multiple location providers.&amp;nbsp; Right now I am able to grab the ESRI Location when it changes here as per the LocationDisplay.LocationChangedListener and then populate X/Y location in the widget.&amp;nbsp; However I end up getting number of satellites from Android location as you can see in the code below from the Android locationManager last known location.&amp;nbsp; I would prefer to get number of satellites from the same source via LocationDisplay.&amp;nbsp; Here is what I am currently doing and it does work just fine...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;lListener &lt;/SPAN&gt;= &lt;SPAN style="color: #000080; font-weight: bold;"&gt;new &lt;/SPAN&gt;LocationDisplay.LocationChangedListener() {&lt;BR /&gt; &lt;SPAN style="color: #808000;"&gt;@Override&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN style="color: #808000;"&gt; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public void &lt;/SPAN&gt;onLocationChanged(LocationDisplay.LocationChangedEvent locationChangedEvent) {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;              double &lt;/SPAN&gt;latitude = locationChangedEvent.getLocation().getPosition().getY();
&lt;SPAN style="color: #000080; font-weight: bold;"&gt;              double &lt;/SPAN&gt;longitude = locationChangedEvent.getLocation().getPosition().getX();
&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Location androidLocation = &lt;SPAN style="color: #660e7a;"&gt;locationManager&lt;/SPAN&gt;.getLastKnownLocation(LocationManager.&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;GPS_PROVIDER&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Integer sats = &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;androidLocation&lt;/SPAN&gt;.getExtras().getInt(&lt;SPAN style="color: #008000; font-weight: bold;"&gt;"satellites"&lt;/SPAN&gt;);&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My thought process was that if I could cast this&amp;nbsp;within the LocationChangedListener..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;NmeaDataSource.Location loc = (NmeaDataSource.Location) locationChangedEvent.getSource().getLocation();&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That I could then&amp;nbsp;get the number of satellites as followed.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Integer sats = loc.getSatellites().size();&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/503074_pastedImage_2.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:30:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/unable-to-cast-locationdatasource-location-to/m-p/593670#M4122</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-12T01:30:05Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to cast LocationDataSource.Location to NmeaDataSource.Location</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/unable-to-cast-locationdatasource-location-to/m-p/593671#M4123</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alright, am going to assume based on lack of response that what I would like to do is not possible with this version of the Runtime SDK.&amp;nbsp; Wondering if&amp;nbsp;satellite information, and other GPS values will be possible to harvest in a future version of the Runtime SDK?&amp;nbsp; Really my main point is that I would like to avoid having to use both Android and ESRI location and associated listeners.&amp;nbsp; It adds unnecessary extra overhead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Aug 2020 15:16:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/unable-to-cast-locationdatasource-location-to/m-p/593671#M4123</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2020-08-21T15:16:53Z</dc:date>
    </item>
  </channel>
</rss>

