-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Data Persistence sample code in documentation throws on Android? #368
Comments
Not all platforms/OS notifyus when the program exits. So it's by design. However you are right that this should be added to the docs here. If you have a free minute a PR would be welcome. |
Thanks for the reply. So if the AutoSuspendHelper approach doesn't work, is there a suggested approach that works on Android? Or do we basically just need to manually write out the config each time any setting changes (in which case, there's really no sense in including the AutoSuspendHelper)? |
I got it working. If you use
|
I have made one. |
Trying to use the sample code per Avalonia's documentation also doesn't work on iOS - it yields So like Android, I'm looking at using ReactiveUI instead: https://www.reactiveui.net/docs/handbook/data-persistence.html However, it requires overriding FinishedLaunching / DidEnterBackground / OnActivated, which it seems like you can't do if you inherit Not really sure how to get app persistence to work beyond Desktop - definitely doesn't work per the documentation :/ |
Ok I think I worked around it like this:
|
@metal450 Can you provide an example on how you were able to do this? It works fine for desktop but I cant get Android working. It always starts up and cant find a state. However If I run that same call to get the state mid operation it succeeds and I can tell I am getting the data I created during that session. But that isnt helping when I need the state to persist between app launches/shutdowns. Its like it isnt saving on shutdown of the app. Here is my app.axaml.cs
}` AkavacheSuspensionDriver.cs
I tried different BlobCache.User and BlobCahce.Secure with no better results. |
Forgot to mention the setup under Androids MainActivity.cs `[Activity(
}` |
Don't really have time to go through all that, but just quickly, I believe this should be everything for Android: MainActivity.cs (in the Android project)
AppState.cs (in the common project)
AppStateDriver.cs (in the common project)
App.axaml.cs (in the common project)
|
Hi,
I've followed the Data Persistence example here: https://docs.avaloniaui.net/docs/concepts/reactiveui/data-persistence
However, the moment it calls
new AutoSuspendHelper(ApplicationLifetime)
on Android, it throwsSystem.NotSupportedException: 'Don't know how to detect app exit event for Avalonia.Android.SingleViewLifetime.'
Is the sample code supposed to function on Android? If not, it would be good if there were a note in the documentation. If so, what might be causing this exception?
Note: the documentation also links to https://github.com/AvaloniaUI/Avalonia/wiki/Application-lifetimes, which not a valid link.
The text was updated successfully, but these errors were encountered: