[英]How to create a setting in an Xamarin Android App that is configurable via App Wrapping
I have created a Xamarin Android App that has a single setting that the user is prompted to enter on first start-up.我创建了一个 Xamarin Android 应用程序,该应用程序有一个设置,提示用户在首次启动时输入。 The setting is then saved using
Xamarin.Essentials.Preferences.Set
and retrieved from then on using Xamarin.Essentials.Preferences.Get
.然后使用 Xamarin.Essentials.Preferences.Set 保存设置,然后使用
Xamarin.Essentials.Preferences.Set
检索Xamarin.Essentials.Preferences.Get
。
I need to make this setting configurable via "App Wrapping".我需要通过“App Wrapping”来配置这个设置。 I have search high and low to work out how to do this, and I am not able to find an example.
我已经搜索了高低以找出如何做到这一点,但我找不到一个例子。
I did want to create the setting in a way where it showed in the Android Settings app (Android Settings/Apps/App Setting for the app), thinking if the setting was accessible in there it would be configurable by App Wrapping, but was not able to find a way of doing this either.我确实想以 Android 设置应用程序(应用程序的 Android 设置/应用程序/应用程序设置)中显示的方式创建设置,考虑是否可以在其中访问设置,它可以通过应用程序包装进行配置,但不是能够找到一种方法来做到这一点。
My app doesn't have a settings UI and doesn't need one, I just need a way to make this one setting configurable via App Wrapping.我的应用没有设置 UI,也不需要,我只需要一种方法来通过 App Wrapping 使这个设置可配置。
Can anyone tell me how to do this?谁能告诉我该怎么做?
I am using the following environment:我正在使用以下环境:
Xamarin.Android.Support.Core.Utils
Xamarin.Android.Support.Design
Xamarin.Android.Support.Supportv4
Xamarin.Essentials
Thank you for your time.感谢您的时间。
So I have found no evidence that in Android you can add a custom setting to the Android Settings app (Android Settings/Apps/App Setting for the app).因此,我没有发现任何证据表明在 Android 中您可以将自定义设置添加到 Android 设置应用程序(应用程序的 Android 设置/应用程序/应用程序设置)。 Instead I have opted to save a file with my setting value to
Xamarin.Essentials.AppDataDirectory
, and this way App Wrapping can be used to pre-configure config value they want in the file.相反,我选择将带有我的设置值的文件保存到
Xamarin.Essentials.AppDataDirectory
,这样可以使用 App Wrapping 在文件中预先配置他们想要的配置值。 If the file is not there when the app starts then I prompt the user for the value on first start-up and write it there.如果应用程序启动时文件不存在,那么我会在第一次启动时提示用户输入值并将其写入那里。 So it can either be pre-configured via App Wrapping or the user can enter it.
所以它既可以通过 App Wrapping 预先配置,也可以由用户输入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.