【发布时间】:2017-07-12 14:27:10
【问题描述】:
我已经实现了如下启动画面 我有一个作为启动 MainActivity 的主启动器的启动程序
[Activity(Theme = "@style/MyTheme.Splash",
MainLauncher = true,
Immersive = true,
ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait,
NoHistory = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class SplashActivity : AppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
var intent = new Intent(this, typeof(MainActivity));
StartActivity(intent);
}
}
在我的 mainactivity 开始时,我注册了所有应用链接并拥有如下所示的意图过滤器。
[Activity(Label = "myapp",
Icon = "@drawable/icon",
Theme = "@style/MyTheme",
MainLauncher = false,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] {
Intent.ActionView,
Intent.CategoryDefault,
Intent.CategoryBrowsable
},
DataScheme = "http",
DataHost = "myapp.azurewebsites.net",
DataPathPrefix = "/app/", AutoVerify = true)
]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] {
Intent.ActionView,
Intent.CategoryDefault,
Intent.CategoryBrowsable
},
DataScheme = "https",
DataHost = "myapp.azurewebsites.net",
DataPathPrefix = "/app/", AutoVerify = true)
]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle bundle)
{
// TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(bundle);
global::Xamarin.Forms.Forms.Init(this, bundle);
AndroidAppLinks.Init(this);
LoadApplication(new App());
}
到目前为止,一切正常,当我单击链接时,它会重定向到我的应用程序并在表单应用程序的 App.Xaml.cs 中点击 OnAppLinkRequestReceived。
protected override async void OnAppLinkRequestReceived(Uri uri)
{
// read link and redirect to a page
}
这里唯一的问题是,单击链接后,用户会看到白屏而不是启动画面。我理解这个问题,因为intentfilters 在mainactivity 上并且从不调用splashactivity。我在飞溅活动中移动了如下所示的意图过滤器, 这次单击链接会显示启动画面,但永远不会调用 OnAppLinkRequestReceived 函数。有谁知道我怎样才能做到这一点?
[Activity(Theme = "@style/MyTheme.Splash",
MainLauncher = true,
Immersive = true,
ScreenOrientation = Android.Content.PM.ScreenOrientation.Portrait,
NoHistory = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] {
Intent.ActionView,
Intent.CategoryDefault,
Intent.CategoryBrowsable
},
DataScheme = "http",
DataHost = "myapp.azurewebsites.net",
DataPathPrefix = "/app/", AutoVerify = true)
]
[IntentFilter(new[] { Intent.ActionView },
Categories = new[] {
Intent.ActionView,
Intent.CategoryDefault,
Intent.CategoryBrowsable
},
DataScheme = "https",
DataHost = "myapp.azurewebsites.net",
DataPathPrefix = "/app/", AutoVerify = true)
]
public class SplashActivity : AppCompatActivity
【问题讨论】:
标签: android xamarin xamarin.android