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。