修复启动屏延时过长的问题;修复主页按返回键后,恢复时错误加载启动页的问题;调整主页模式为SingleTask。

TangShanKaiPing
wanggang 6 years ago
parent 7e3a2f141b
commit 7f46ed7ba2

@ -5,7 +5,7 @@ using LibVLCSharp.Forms.Shared;
namespace Demo.Droid
{
[Activity(Label = "Demo", Icon = "@mipmap/icon", Theme = "@style/MainTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[Activity(Label = "Demo", Icon = "@mipmap/icon", Theme = "@style/MainTheme", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, LaunchMode = LaunchMode.SingleTask)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate(Bundle savedInstanceState)
@ -25,5 +25,10 @@ namespace Demo.Droid
{
ZXing.Net.Mobile.Android.PermissionsHandler.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
public override void OnBackPressed()
{
this.MoveTaskToBack(true);
}
}
}

@ -2,7 +2,6 @@
using Android.Content;
using Android.OS;
using Android.Support.V7.App;
using Android.Util;
using System.Threading.Tasks;
namespace Demo.Droid
@ -10,15 +9,11 @@ namespace Demo.Droid
[Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory = true)]
public class SplashActivity : AppCompatActivity
{
private static readonly string TAG = "X:" + typeof(SplashActivity).Name;
public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
{
base.OnCreate(savedInstanceState, persistentState);
Log.Debug(TAG, "SplashActivity.OnCreate");
}
// Launches the startup task
protected override void OnResume()
{
base.OnResume();
@ -26,14 +21,10 @@ namespace Demo.Droid
startupWork.Start();
}
// Simulates background work that happens behind the splash screen
private async void SimulateStartup()
{
Log.Debug(TAG, "Performing some startup work that takes a bit of time.");
await Task.Delay(8000); // Simulate a bit of startup work.
Log.Debug(TAG, "Startup work is finished - starting MainActivity.");
await Task.Delay(1);
StartActivity(new Intent(Application.Context, typeof(MainActivity)));
}
public override void OnBackPressed() { }
}
}
Loading…
Cancel
Save