AnsweredAssumed Answered

Issue with loading mobile map package .NET for Android Xamarin

Question asked by Yifan_Liu-esristaff Employee on Jul 3, 2017
Latest reply on Jul 5, 2017 by Yifan_Liu-esristaff

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

 

  private async Task<MobileMapPackage> LoadMMPK()
        {
            try
            {
                var mmpkName = "map.mmpk";
                AssetManager assestManager = this.Assets;

                // Open the map package asset
                using (var packageAsset = Assets.Open(mmpkName))
                {
                    // Copy it to a writable location
                    using (var packageTarget = OpenFileOutput(mmpkName, FileCreationMode.WorldWriteable))
                    {
                        packageAsset.CopyTo(packageTarget);
                    }
                }

                var mmpkPath = GetFileStreamPath(mmpkName).AbsolutePath;
                MobileMapPackage mmpk = await MobileMapPackage.OpenAsync(mmpkPath);
               
                return mmpk;
            }
            catch (FileNotFoundException ex)
            {
                Console.Write(ex.Message);
                return null;
            }
        }

Outcomes