c# - Xamarin Forms (Android): OnCreate bundle is null -
i have android project, , wish store api keys in android manifest file. read them, can read bundle comes through in oncreate
override in mainactivity
class: viz
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 api key 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
there 1 small problem. bundle
null. happening in of projects, in both c# , f# implementations.
i'm using xamarin.forms nuget package, version 2.3.4.224.
instead of trying use bundle
argument, possible retrieve metadata follows:
let metadata = packagemanager.getapplicationinfo(packagename, packageinfoflags.metadata).metadata let platform = new droidplatform(metadata.getstring(myapikey)) :> icustomplatform
Comments
Post a Comment