C# 当应用程序开始共享时,如何调用旧的意图?
我想解释一下我的应用程序逻辑。我的应用程序正在查看PDF。有两种方式显示PDFC# 当应用程序开始共享时,如何调用旧的意图?,c#,android,pdf,xamarin.forms,C#,Android,Pdf,Xamarin.forms,我想解释一下我的应用程序逻辑。我的应用程序正在查看PDF。有两种方式显示PDF 用户登录应用程序并单击“显示PDF”按钮。然后,应用程序打开一个新窗口,用户选择一个pdf来查看它 用户从手机存储器中打开pdf,并将该pdf共享到我的应用程序中。(如果用户以前未登录应用程序,应用程序将打开登录页面。) 第一个很好用。但当用户从手机存储器中向我的应用程序共享pdf文件时,应用程序会自动打开我的主页 应用程序中有2个公共登录页(){} 1.公共登录页() 2.公共登录页面(字符串) 第一个允许用户登录
protected override async void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
ZXing.Net.Mobile.Forms.Android.Platform.Init();
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
LoadApplication(new App());
Share();
}
private void Share()
{
//Some codes for share
Navigate(path);
}
public async void Navigate(string path)
{
await Xamarin.Forms.Application.Current.MainPage.Navigation.PushModalAsync(new LoginPage(path));
}
LoginPage.cs
public LoginPage(string _pdfUri)
{
this.PdfUri = _pdfUri;
CheckSessionWithUri(_pdfUri); //it checks session and send pdf path to PDFshowPage.
}
public LoginPage()
{
CheckSession(); //it sends user to the HomePage if the user correctly login or the user has login before.
}
我想控制当用户将pdf共享到我的应用程序时,应用程序必须将他发送到PdfShowPage。我们应该在App.xaml.cs或其他地方控制它吗
谢谢。也许您可以将
\u pdfUri
传递到应用程序
类,然后基于\u pdfUri
打开登录页面
。比如:
protected override async void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
ZXing.Net.Mobile.Forms.Android.Platform.Init();
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
Share();
}
private void Share()
{
//Some codes for share
LoadApplication(new App(_pdfUri));
}
然后
是的,实际上应该是工作。在我打开这个问题之后,我已经解决了这个问题。我添加了一个具有bool值的类,当我使用share方法时,它保存该值并返回该值。谢谢你的回答,利奥!
protected override async void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
ZXing.Net.Mobile.Forms.Android.Platform.Init();
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
Share();
}
private void Share()
{
//Some codes for share
LoadApplication(new App(_pdfUri));
}
public App(string _pdfUri)
{
InitializeComponent();
if(path !=null){
MainPage = new NavigationPage(new LoginPage(_pdfUri))
{
BarBackgroundColor = Color.FromHex("008000"),
BarTextColor = Color.FromHex("E8E8E8")
};
}else{
MainPage = new NavigationPage(new LoginPage())
{
BarBackgroundColor = Color.FromHex("008000"),
BarTextColor = Color.FromHex("E8E8E8")
};
}
}