Application.Current.Properties dont work in Xamarin 2.0

alekssmykalekssmyk USMember ✭✭✭

Hi!
Today I have updated my project and Application.Current.Properties dont work correctly. I could save value and read it while my app running, but is i stop and run agarin, Application.Current.Properties is empty. Thank you for help.

Tagged:

Best Answer

Answers

  • karbokarbo DEMember

    Hi!
    I have the same issue. The solution of Stefano does NOT work for me, any other ideas? Thanks!
    Karsten

  • DanielLDanielL PLInsider ✭✭✭✭

    Did you try to do forced save?

    await Application.Current.SavePropertiesAsync();

  • EricSchmitzEricSchmitz USUniversity ✭✭

    I have noticed the same issue. In XF versions prior to 2.0, the settings saved in Application.Current.Properties would survive a swipe up to clear the app from memory. Now they do not. Waiting to hear if this is intentional or not.

  • alekssmykalekssmyk USMember ✭✭✭

    Hi everyone. Thank you for the messages. I started to use https://github.com/jamesmontemagno/Xamarin.Plugins/tree/master/Settings. It works fine with xf updates and it is simple in use.

  • ReinVReinV BEMember ✭✭

    Anyone know if this is intentional or a bug in the current version ?

  • EZHartEZHart USXamarin Team Xamurai

    @deandean @karbo @EricSchmitz Are you seeing this on a specific platform (iOS, Android, Windows) or is it common to all platforms?

  • EricSchmitzEricSchmitz USUniversity ✭✭

    I noticed it in iOS and did not test the behavior on the Android side. I have since refactored the code to use Montemagno's Settings plugin.

  • CSNTAndroidCSNTAndroid CNMember

    I have this issue too in android platform.It is caused by Xamarin.Android 4.0 but not Forms 2.0

  • I have this happening on XF2 even on a very fresh app.

    protected override void OnStart()
    {
       if (!Current.Properties.ContainsKey ("key")) {
           Current.Properties.Add("key", "test");
           // was not using SavePropertiesAsync with 1.4x and would still work just fine
           SavePropertiesAsync ();
       }
       else
           Debug.WriteLine("Found");
    }
    

    Will never find anything. Was working fine before the upgrade.

    Test is done launching app from VS on iOS Simulator (Mac), if that's of any help

  • karbokarbo DEMember

    I had the issue on android, did not test the other platforms.
    Going back to Forms 1.5 didn't help, so now I use the settings-plugin from jamesmontemagno. Works fine.

  • KarlKoppKarlKopp AUMember ✭✭

    @karbo said:
    I had the issue on android, did not test the other platforms.
    Going back to Forms 1.5 didn't help, so now I use the settings-plugin from jamesmontemagno. Works fine.

    I had to do the same to get Properties to persist - built in mechanism didn't work, used James plugin in the end to get it saving...

  • EZHartEZHart USXamarin Team Xamurai

    We're still looking into this issue, but in the meantime this workaround might address the problem for some applications: https://forums.xamarin.com/discussion/comment/169577/#Comment_169577

  • DarrenMcGrath86DarrenMcGrath86 GBMember ✭✭

    I am having the issue in my Xamarin Forms project on Android devices.

    I can save and access data in Application.Current.Properties in debug mode but it fails in release mode.

  • Fails for me in Android Debug as well.

  • kishorsonejikishorsoneji INMember
    edited April 2016

    Application.Current.SavePropertiesAsync() not working, gives error missing assembly reference of SavePropertiesAsync, and not saving my data into apllication.cureent.properties [];
    any solution?

  • ChaseFlorellChaseFlorell CAInsider, University mod

    I ended up having to revert to @JamesMontemagno's settings plugin (didn't feel like writing it myself). Happening on Android when the app is killed and restarted.

Sign In or Register to comment.