0

I'm working on Xamarin Android and I need to show a images carousel when application start.

I have seen some implementations with Java Shared Preferences, but I don't know how to do this with Xamarin. Could you help me?

Thanks a lot!

user3535054
  • 77
  • 1
  • 11

2 Answers2

2

To access shared prefs on Xamarin:

ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences (this);

Then to check for a "firstRun" using shared preferences:

            if (prefs.GetBoolean ("firstRun", true)) {
                LaunchImagesCarousel ();
                prefs.Edit ().PutBoolean ("firstRun", false).Commit ();
            } else {
               // something else
            }

I use the same approach to display a tutorial of carousel images if its user's first time opening the app.

If this is deemed redundant, unnecessary and/or likely answered elsewhere, please do remove it.

MikeOscarEcho
  • 535
  • 2
  • 12
  • 27
0

With Xamarin Forms you can do VersionTracking.IsFirstLaunchEver
https://learn.microsoft.com/en-us/xamarin/essentials/version-tracking

Stuart Hallows
  • 8,795
  • 5
  • 45
  • 57