<?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 GPS on Android not Working in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/gps-on-android-not-working/m-p/97699#M1032</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've got a Xamarin Forms application with some GPS functionality that has been working great for years.&amp;nbsp; Since we've upgraded to 100.4 our GPS functionality is not working on Android.&amp;nbsp; Still works great on iOS though.&amp;nbsp; Basically as soon as we set the IsEnabled property on the MapView.LocationDisplay to true it immediately resets itself to false.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We've tested this on two different Android devices, one with 6.0.1, and one with 7.1.1.&amp;nbsp; Doesn't work on either.&amp;nbsp; I've attached a repro solution here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Dec 2018 18:25:40 GMT</pubDate>
    <dc:creator>AndyWright</dc:creator>
    <dc:date>2018-12-13T18:25:40Z</dc:date>
    <item>
      <title>GPS on Android not Working</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/gps-on-android-not-working/m-p/97699#M1032</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've got a Xamarin Forms application with some GPS functionality that has been working great for years.&amp;nbsp; Since we've upgraded to 100.4 our GPS functionality is not working on Android.&amp;nbsp; Still works great on iOS though.&amp;nbsp; Basically as soon as we set the IsEnabled property on the MapView.LocationDisplay to true it immediately resets itself to false.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We've tested this on two different Android devices, one with 6.0.1, and one with 7.1.1.&amp;nbsp; Doesn't work on either.&amp;nbsp; I've attached a repro solution here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Dec 2018 18:25:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/gps-on-android-not-working/m-p/97699#M1032</guid>
      <dc:creator>AndyWright</dc:creator>
      <dc:date>2018-12-13T18:25:40Z</dc:date>
    </item>
    <item>
      <title>Re: GPS on Android not Working</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/gps-on-android-not-working/m-p/97700#M1033</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, Andy!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The LocationDisplay component is powered by a&amp;nbsp;Location&lt;SPAN&gt;DataSource. When you&amp;nbsp;set LocationDisplay.IsEnabled to true, it will try&amp;nbsp;starting its data source.&amp;nbsp;If for some reason it cannot be started successfully,&amp;nbsp;&lt;/SPAN&gt;this property will automatically reset to "false".&amp;nbsp;To get more detail about the failure, you can use the &lt;SPAN&gt;Location&lt;/SPAN&gt;&lt;SPAN&gt;D&lt;/SPAN&gt;&lt;SPAN&gt;ata&lt;/SPAN&gt;&lt;SPAN&gt;S&lt;/SPAN&gt;&lt;SPAN&gt;ource.&lt;/SPAN&gt;StartAsync() method directly. Awaiting the Task will give you access to an Exception with details. For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;private&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;async&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;Button_Clicked&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;object&lt;/SPAN&gt; sender&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; System&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;EventArgs e&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; locationDataSource &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; map&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;LocationDisplay&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;DataSource&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;try&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;await&lt;/SPAN&gt; locationDataSource&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;StartAsync&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="keyword token"&gt;catch&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="token class-name"&gt;Exception&lt;/SPAN&gt; ex&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Debug&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;WriteLine&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"Could start LocationDataSource. Details: "&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; ex&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In this case, looks like LocationDataSource is failing to start due to a permission issue:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;[0:] Could not access location. Details: Java.Lang.SecurityException: "gps" location provider requires ACCESS_FINE_LOCATION permission.&lt;BR /&gt; at Esri.ArcGISRuntime.Location.SystemLocationDataSource+&amp;lt;OnStartAsync&amp;gt;d__3.MoveNext () [0x0013a]&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This will happen on Android 6.0+ because the OS no longer automatically grants&amp;nbsp;certain permissions — apps have to make an additional API call to request them. You have several options&amp;nbsp;for doing this in a Xamarin Forms app (e.g. by using the open-source&amp;nbsp;&lt;A href="https://github.com/jamesmontemagno/PermissionsPlugin" rel="nofollow noopener noreferrer" target="_blank"&gt;PermissionsPlugin&lt;/A&gt;&amp;nbsp;library or by &lt;A href="https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/permissions?tabs=windows#runtime-permission-checks-in-android-60" rel="nofollow noopener noreferrer" target="_blank"&gt;calling Android APIs directly&lt;/A&gt;). After modifying this app to request location permission, I was able to&amp;nbsp;display location:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="j-img-floatstart image-1 jive-image" height="504" src="https://community.esri.com/legacyfs/online/431675_Screenshot_20181213-190125.jpg" style="float: left;" width="300" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="image-2 jive-image" height="534" src="https://community.esri.com/legacyfs/online/431676_Screenshot_20181213-192006.jpg" width="300" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope this helps!&lt;/P&gt;&lt;P&gt;- Matvei Stefarov&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:07:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/gps-on-android-not-working/m-p/97700#M1033</guid>
      <dc:creator>MatveiStefarov</dc:creator>
      <dc:date>2021-12-11T06:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: GPS on Android not Working</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/gps-on-android-not-working/m-p/97701#M1034</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Matvei.&amp;nbsp; This definitely helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 17 Jan 2019 18:10:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/gps-on-android-not-working/m-p/97701#M1034</guid>
      <dc:creator>AndyWright</dc:creator>
      <dc:date>2019-01-17T18:10:11Z</dc:date>
    </item>
  </channel>
</rss>

