<?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: When is it not safe to call MapView.getScale() and MapView.GetVisibleArea()? in ArcGIS Runtime SDK for Android Questions</title>
    <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219245#M1429</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I cannot prove it, but I suspect this could be called after onDestroy and therefore &lt;/P&gt;&lt;P&gt;Does that sound likely?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could the event handler get called if it is still in queue after the disposal?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 05 Nov 2018 20:41:05 GMT</pubDate>
    <dc:creator>NathanMellor</dc:creator>
    <dc:date>2018-11-05T20:41:05Z</dc:date>
    <item>
      <title>When is it not safe to call MapView.getScale() and MapView.GetVisibleArea()?</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219240#M1424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We get some crash reports sometimes that we don't quite understand.&lt;/P&gt;&lt;P&gt;I understand that there are times when the MapView is not ready to return information like Scale and VisibleArea.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But how do I tell when it is safe? Crashing isn't very user friendly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example 1:&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;com.esri.arcgisruntime.internal.jni.CoreMapView.nativeGetScale&lt;/SPAN&gt; &lt;SPAN class=""&gt; (SourceFile) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;com.esri.arcgisruntime.internal.jni.CoreMapView.q&lt;/SPAN&gt; &lt;SPAN class=""&gt; (SourceFile&lt;SPAN class=""&gt;:233&lt;/SPAN&gt;) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;com.esri.arcgisruntime.internal.h.b.o.m&lt;/SPAN&gt; &lt;SPAN class=""&gt; (SourceFile&lt;SPAN class=""&gt;:224&lt;/SPAN&gt;) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;com.esri.arcgisruntime.mapping.view.MapView.getMapScale&lt;/SPAN&gt; &lt;SPAN class=""&gt; (SourceFile&lt;SPAN class=""&gt;:295&lt;/SPAN&gt;) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;....HomeActivity.updateZoomLevelText&lt;/SPAN&gt; &lt;SPAN class=""&gt; (BCHomeActivity.java&lt;SPAN class=""&gt;:687&lt;/SPAN&gt;) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;...HomeActivity.access$000&lt;/SPAN&gt; &lt;SPAN class=""&gt; (BCHomeActivity.java&lt;SPAN class=""&gt;:203&lt;/SPAN&gt;) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;...HomeActivity$1.mapScaleChanged&lt;/SPAN&gt; &lt;SPAN class=""&gt; (BCHomeActivity.java&lt;SPAN class=""&gt;:366&lt;/SPAN&gt;) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt; &lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN&gt;com.esri.arcgisruntime.internal.h.b.n$1.run&lt;/SPAN&gt; &lt;SPAN class=""&gt; (SourceFile&lt;SPAN class=""&gt;:58&lt;/SPAN&gt;) &lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sure there are times when the scale can't be read. But I don't think one of those times should be when you just called us to tell us the scale changed. That seems like a time when we can get a scale and update the zoomlevel. But nope, it crashes. Not all the time, but some of the time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;A bit ridiculous?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is there some method available like boolean MapView isItSafetoAskforScale() ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Because the only other alternative I can think of is to handle an exception every time we call MapView.getMapScale().&lt;/P&gt;&lt;P&gt;Or just let it crash.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 22 Sep 2018 01:55:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219240#M1424</guid>
      <dc:creator>NathanMellor</dc:creator>
      <dc:date>2018-09-22T01:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: When is it not safe to call MapView.getScale() and MapView.GetVisibleArea()?</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219241#M1425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Nathan,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you share more details to help us reproduce this problem? I can access the MapView's scale OK in a MapScaleChangedListener, and I'm using ArcGIS Runtime SDK for Android 100.3. Let us know about your device, which version of Android you have, and ideally some simple code that shows&amp;nbsp;the problem for you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shelly&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Sep 2018 11:53:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219241#M1425</guid>
      <dc:creator>ShellyGill1</dc:creator>
      <dc:date>2018-09-25T11:53:56Z</dc:date>
    </item>
    <item>
      <title>Re: When is it not safe to call MapView.getScale() and MapView.GetVisibleArea()?</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219242#M1426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It occurs in Android 6-9&lt;/P&gt;&lt;P&gt;I do not have simple code to reproduce it. It does not happen all the time, but happens fairly often for actual users. If I knew what triggers it, I'd be closer to fixing it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code is in onCreate() of the activity.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;mMapView&lt;/SPAN&gt;.addMapScaleChangedListener(&lt;SPAN style="color: #000080; font-weight: bold;"&gt;new &lt;/SPAN&gt;MapScaleChangedListener() {

&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #808000;"&gt;@Override
&lt;/SPAN&gt;&lt;SPAN style="color: #808000;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;public void &lt;/SPAN&gt;mapScaleChanged(MapScaleChangedEvent mapScaleChangedEvent) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; updateZoomLevelText();
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
});

This code is in a local method. Only important thing here is that we are calling getMapScale. 
&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="color: #000080; font-weight: bold;"&gt;private void &lt;/SPAN&gt;updateZoomLevelText() {
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;tvZoomLevel&lt;/SPAN&gt;.setText(String.&lt;SPAN style="font-style: italic;"&gt;valueOf&lt;/SPAN&gt;(BC_Helper.&lt;SPAN style="font-style: italic;"&gt;getZoomLevelByScale&lt;/SPAN&gt;(&lt;SPAN style="color: #660e7a; font-weight: bold;"&gt;mMapView&lt;/SPAN&gt;.getMapScale())));
}&lt;/PRE&gt;Only thing that occurs to me is that somehow we are getting this event at a point in the Activity lifecycle &lt;BR /&gt;where the activity, and therefore the MapView, is no longer valid. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:41:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219242#M1426</guid>
      <dc:creator>NathanMellor</dc:creator>
      <dc:date>2021-12-11T10:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: When is it not safe to call MapView.getScale() and MapView.GetVisibleArea()?</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219243#M1427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;&amp;nbsp;Only thing that occurs to me is that somehow we are getting this event at a point in the Activity lifecycle &lt;BR /&gt;where the activity, and therefore the MapView, is no longer valid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Perhaps something is hanging on to a callback when it should have been disposed - have you got calls to pause and dispose the MapView in the activities onPause and onDestroy methods (e.g.&amp;nbsp;&lt;A href="https://developers.arcgis.com/android/latest/guide/develop-your-first-map-app.htm#ESRI_SECTION1_38DA9293B8B546B38D2BC7E78013F1F3"&gt;like shown here&lt;/A&gt;&amp;nbsp;)? Let me know, and I will pass on this info and post back if we can find the cause or if there's a workaround.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shelly&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Oct 2018 11:55:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219243#M1427</guid>
      <dc:creator>ShellyGill1</dc:creator>
      <dc:date>2018-10-12T11:55:57Z</dc:date>
    </item>
    <item>
      <title>Re: When is it not safe to call MapView.getScale() and MapView.GetVisibleArea()?</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219244#M1428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did check and we do have calls to pause and dispose the mapview at the right time. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 17 Oct 2018 17:40:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219244#M1428</guid>
      <dc:creator>NathanMellor</dc:creator>
      <dc:date>2018-10-17T17:40:32Z</dc:date>
    </item>
    <item>
      <title>Re: When is it not safe to call MapView.getScale() and MapView.GetVisibleArea()?</title>
      <link>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219245#M1429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I cannot prove it, but I suspect this could be called after onDestroy and therefore &lt;/P&gt;&lt;P&gt;Does that sound likely?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could the event handler get called if it is still in queue after the disposal?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Nov 2018 20:41:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-runtime-sdk-for-android-questions/when-is-it-not-safe-to-call-mapview-getscale-and/m-p/219245#M1429</guid>
      <dc:creator>NathanMellor</dc:creator>
      <dc:date>2018-11-05T20:41:05Z</dc:date>
    </item>
  </channel>
</rss>

