我正在尝试使用以下代码在我的应用程序中使用默认的Android PDF查看器查看托管的PDF文件:
var intent = new Intent(Intent.ActionView);
intent.SetDataAndType(Uri.Parse("http://sample/url.pdf"), "application/pdf");
intent.SetFlags(ActivityFlags.ClearTop);
Android.Content.Context.StartActivity(intent);
我在一个原生项目中使用过这段代码,所以我知道它可以在Android活动中工作。对于Xamarin Forms,是否有办法让我从内容页面启动Android活动,反之亦然?
Forms.Context
在版本2.5中已经过时。 - Ash[assembly: Xamarin.Forms.Dependency(typeof(NativePages))]
装饰器已经在依赖服务中注册了接口,因此不需要显式地使用Xamarin.Forms.DependencyService.Register<INativePages>();
。 - CodingLumis