Hi,
I am developing a Xamarin app for Android using the arcGIS .NET for Android SDK. I am trying to load a mobile map package with this method shown below. My problem is that on line 19, the OpenAsync never return and the await never yield the control to the caller of this LoadMMPK() method. My application gets stuck here.
A bit of explanation of the code: The mobile map package is in the Asset folder of my Android project, which gets copied to the android device (line 6 to 16). Then I call the OpenAsync on line 19 to load the mmpk. I checked the Android device, the map package was successfully written into the device, and the mmpkPath passed into the OpenAsync method is valid and points to the right mobile map package.
Anyone can help me point out what might be the cause of my issue here? Thank you
<SPAN class="keyword token">private</SPAN> <SPAN class="keyword token">async</SPAN> Task<SPAN class="operator token"><</SPAN>MobileMapPackage<SPAN class="operator token">></SPAN> <SPAN class="token function">LoadMMPK</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">try</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> mmpkName <SPAN class="operator token">=</SPAN> <SPAN class="string token">"map.mmpk"</SPAN><SPAN class="punctuation token">;</SPAN>
AssetManager assestManager <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">this</SPAN><SPAN class="punctuation token">.</SPAN>Assets<SPAN class="punctuation token">;</SPAN>
<SPAN class="comment token">// Open the map package asset</SPAN>
<SPAN class="keyword token">using</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">var</SPAN> packageAsset <SPAN class="operator token">=</SPAN> Assets<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Open</SPAN><SPAN class="punctuation token">(</SPAN>mmpkName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">// Copy it to a writable location</SPAN>
<SPAN class="keyword token">using</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="keyword token">var</SPAN> packageTarget <SPAN class="operator token">=</SPAN> <SPAN class="token function">OpenFileOutput</SPAN><SPAN class="punctuation token">(</SPAN>mmpkName<SPAN class="punctuation token">,</SPAN> FileCreationMode<SPAN class="punctuation token">.</SPAN>WorldWriteable<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
packageAsset<SPAN class="punctuation token">.</SPAN><SPAN class="token function">CopyTo</SPAN><SPAN class="punctuation token">(</SPAN>packageTarget<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">var</SPAN> mmpkPath <SPAN class="operator token">=</SPAN> <SPAN class="token function">GetFileStreamPath</SPAN><SPAN class="punctuation token">(</SPAN>mmpkName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>AbsolutePath<SPAN class="punctuation token">;</SPAN>
MobileMapPackage mmpk <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">await</SPAN> MobileMapPackage<SPAN class="punctuation token">.</SPAN><SPAN class="token function">OpenAsync</SPAN><SPAN class="punctuation token">(</SPAN>mmpkPath<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> mmpk<SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="keyword token">catch</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="token class-name">FileNotFoundException</SPAN> ex<SPAN class="punctuation token">)</SPAN>
<SPAN class="punctuation token">{</SPAN>
Console<SPAN class="punctuation token">.</SPAN><SPAN class="token function">Write</SPAN><SPAN class="punctuation token">(</SPAN>ex<SPAN class="punctuation token">.</SPAN>Message<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">return</SPAN> <SPAN class="keyword token">null</SPAN><SPAN class="punctuation token">;</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>