2
我有一個Android項目,我希望將我的API密鑰存儲在我的Android Manifest文件中。讀他們,我可以讀,在OnCreate
覆蓋來通過我的MainActivity
類的包:即Xamarin Forms(Android):OnCreate bundle爲null
type MainActivity() =
inherit FormsApplicationActivity()
static let [<Literal>] MyApiKey = "my-api-key"
override this.OnCreate (bundle) =
base.OnCreate(bundle)
let createViewModel() = new PhotoSetViewModel() :> IRoutableViewModel
AppDomain.CurrentDomain.UnhandledException.AddHandler(UnhandledExceptionEventHandler(AppExceptions.processException))
Forms.Init(this, bundle)
Xamarin.FormsMaps.Init(this, bundle)
// Read the API key that I've stored in AndroidManifest.xml
let platform = new DroidPlatform(bundle.GetString(MyApiKey)) :> ICustomPlatform
let app = new App<ICustomPlatform>(platform, new UiContext(this), createViewModel)
app.Init()
base.LoadApplication app
有一個小問題。 bundle
始終爲空。在我的所有項目中,C#和F#實現都發生這種情況。
我正在使用Xamarin.Forms NuGet包,版本2.3.4.224。