From 7f46ed7ba2e2c731bdf750b893b13984268c1d0a Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Wed, 24 Apr 2019 09:41:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=AF=E5=8A=A8=E5=B1=8F?= =?UTF-8?q?=E5=BB=B6=E6=97=B6=E8=BF=87=E9=95=BF=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9B=E4=BF=AE=E5=A4=8D=E4=B8=BB=E9=A1=B5=E6=8C=89=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E9=94=AE=E5=90=8E=EF=BC=8C=E6=81=A2=E5=A4=8D=E6=97=B6?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=8A=A0=E8=BD=BD=E5=90=AF=E5=8A=A8=E9=A1=B5?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=9B=E8=B0=83=E6=95=B4=E4=B8=BB?= =?UTF-8?q?=E9=A1=B5=E6=A8=A1=E5=BC=8F=E4=B8=BASingleTask=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projects/Demo/Demo.Android/MainActivity.cs | 7 ++++++- projects/Demo/Demo.Android/SplashActivity.cs | 11 +---------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/projects/Demo/Demo.Android/MainActivity.cs b/projects/Demo/Demo.Android/MainActivity.cs index 6d5de839..555827f9 100644 --- a/projects/Demo/Demo.Android/MainActivity.cs +++ b/projects/Demo/Demo.Android/MainActivity.cs @@ -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); + } } } \ No newline at end of file diff --git a/projects/Demo/Demo.Android/SplashActivity.cs b/projects/Demo/Demo.Android/SplashActivity.cs index 6e61df50..6b7fe787 100644 --- a/projects/Demo/Demo.Android/SplashActivity.cs +++ b/projects/Demo/Demo.Android/SplashActivity.cs @@ -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() { } } } \ No newline at end of file