protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App()); // 在调用TBS初始化、创建WebView之前进行如下配置 var dic = new System.Collections.Generic.Dictionary <string, Java.Lang.Object> { { TbsCoreSettings.TbsSettingsUseSpeedyClassloader, true }, { TbsCoreSettings.TbsSettingsUseDexloaderService, true }, }; QbSdk.InitTbsSettings(dic); preInitCallback = new PreInitCallback(); tbsListener = new TbsListener(); MessagingCenter.Subscribe <object>(this, WebPage.InitX5, o => { //QbSdk.DownloadWithoutWifi = true; QbSdk.SetTbsListener(tbsListener); QbSdk.InitX5Environment(this, preInitCallback); }); MessagingCenter.Subscribe <object>(this, WebPage.PlayVideo, o => { TbsVideo.OpenVideo(this, "http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4"); }); MessagingCenter.Subscribe <object>(this, WebPage.OpenFile, async o => { var backingFile = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "excel.xlsx"); if (System.IO.File.Exists(backingFile) == false) { using (var stream = Assets.Open("excel.xlsx")) { using (var newStream = System.IO.File.Create(backingFile)) { await stream.CopyToAsync(newStream); } } } var dic = new System.Collections.Generic.Dictionary <string, string> { { "local", "true" } }; var openResult = QbSdk.OpenFileReader(this, backingFile, dic, new ValueCallback()); }); }
protected override void OnCreate(Bundle savedInstanceState) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); global::Xamarin.Forms.Forms.Init(this, savedInstanceState); LoadApplication(new App()); preInitCallback = new PreInitCallback(); tbsListener = new TbsListener(); MessagingCenter.Subscribe <object>(this, WebPage.InitX5, o => { //QbSdk.DownloadWithoutWifi = true; QbSdk.SetTbsListener(tbsListener); QbSdk.InitX5Environment(this, preInitCallback); }); MessagingCenter.Subscribe <object>(this, WebPage.PlayVideo, o => { TbsVideo.OpenVideo(this, "http://vfx.mtime.cn/Video/2019/02/04/mp4/190204084208765161.mp4"); }); MessagingCenter.Subscribe <object>(this, WebPage.OpenFile, async o => { var backingFile = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "excel.xlsx"); if (System.IO.File.Exists(backingFile) == false) { using (var stream = Assets.Open("excel.xlsx")) { using (var newStream = System.IO.File.Create(backingFile)) { await stream.CopyToAsync(newStream); } } } var openResult = QbSdk.OpenFileReader(this, backingFile, null, new ValueCallback()); }); }