是否可以使用xamarin.form在我的应用程序中打开另一个应用程序? [英] Is it possible to open another app in my app with xamarin.form?
问题描述
我是新来的频道;我最近开始使用xamarin.form来开发跨平台应用程序.
I'm new in the channel; I recently started with xamarin.form for cross-plattform apps.
我已经被问题困扰了几天.我想知道是否有一种方法可以让我的应用程序打开第三方应用程序,或者有必要以不同的方式为每个平台实现此功能.
I've been stuck with a question for a few days. I would like to know if there is a method that allow me to open a third-party application by my app or it's necessary to implement this function for each platform in a different way.
确切地说,我想知道是否有一种方法类似于UIWebview中IFrame为网页提供的方法,以在我的应用程序中打开第三方应用程序而无需启动第二个应用程序在后台发送我的应用程序?
Precisely, I would like to know if there is a method similar to that provided by IFrame in UIWebview for web pages to open third-party apps in my app without launching the second app sending my app in background?
推荐答案
您可以尝试一下;
private async void Button_OnClicked(object sender, EventArgs e)
{ //You need to change your app package address which you want to open with button. Example: "com.microsoft.office.officelens"
Intent intent = new Intent();
intent.SetComponent(new ComponentName("com.package.address", "com.package.address.MainActivity"));
Android.App.Application.Context.StartActivity(intent);
}
此外,如果您要检查用户已下载或未下载此应用;
Also, if you want to check user downloaded or didn't download this app;
public string facebookApp;
public async Task ShowAlert()
{
this.facebookApp = "https://play.google.com/store/apps/details?id=com.facebook.katana&hl=tr";
var action = await DisplayAlert("Warning", "Please download facebook app first.", "Okay", "Cancel");
if (action)
{
Device.OpenUri(new Uri(this.facebookApp));
}
}
private async void Button_OnClicked(object sender, EventArgs e)
{
try
{
Intent intent = new Intent();
intent.SetComponent(new ComponentName("com.package.address", "com.package.address.MainActivity"));
Android.App.Application.Context.StartActivity(intent);
}
catch (Exception ex)
{
ShowAlert();
}
}
因此,在这种情况下;如果用户之前未下载xApp(facebook,twitter等),他/她将收到警告.如果他们在DisplayAlert上单击确定",则程序会将其发送到Google Play链接.
So, in this case; if the user didn't download xApp(facebook, twitter, etc.) before, he/she will get a warning. If they click Okay on DisplayAlert, the program will send them to Google Play link.
这篇关于是否可以使用xamarin.form在我的应用程序中打开另一个应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!