2016-05-10 18 views
1

スプラッシュ画面の読み込み中にアプリケーションを最小化すると、アプリケーションタイトルの黒い画面が表示され、しばらくしてから最初の画面も表示されます。ここに私のスプラッシュアクティビティとメインアクティビティクラスがあります。Xamarinがスプラッシュ画面の問題を解決する

[Activity(Theme = "@style/Theme.Splash", Icon = "@drawable/icon", MainLauncher = true, NoHistory = true, 
    ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, 
    ScreenOrientation = ScreenOrientation.Behind)] 
public class SplashActivity : Activity 
{ 
    protected override void OnCreate(Bundle bundle) 
    { 
     base.OnCreate(bundle); 

     var dpWidth = Resources.DisplayMetrics.WidthPixels/Resources.DisplayMetrics.Density; 


     RequestedOrientation = dpWidth > 700 ? ScreenOrientation.Unspecified : ScreenOrientation.Portrait; 

     ThreadPool.QueueUserWorkItem(o => LoadActivity()); 
    } 

    private void LoadActivity() 
    { 

     RunOnUiThread(() => StartActivity(typeof(MainActivity))); 
    } 


    public override void OnBackPressed() 
    { 
     Environment.Exit(0); 
    } 
} 



[Activity(Label = "HACCP", ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)] 
public class MainActivity : FormsApplicationActivity 
{ 


    protected override void OnCreate(Bundle bundle) 
    { 
     base.OnCreate(bundle); 
     ActionBar.SetIcon(Android.Resource.Color.Transparent); 

     Forms.Init(this, bundle); 

     // some function // 

     LoadApplication(new App()); 
    } 

} 
+0

問題が固定されている。..ほど単純でなければなりませんので、あなたはXamarin.Formsをタグ付け。 –

答えて

0

ない特定のアクティビティ属性ScreenOrientation = ScreenOrientation.Behind)はすべての問題を引き起こしている場合、我々は我々のアプリでそれを使用しないでください。ここで

はXamarin.Androidがタイミングなどの世話をさせる、私たちが使用しない「標準」スプラッシュ活動です:

public class SplashActivity : Activity 
{ 
    protected override void OnCreate(Bundle bundle) 
    { 
     base.OnCreate(bundle); 

     // Start main. 
     StartActivity(typeof(MainActivity)); 
    } 
} 

あなたは同様の方法でアプリケーションを簡素化してみてください。

1

falseにNoHistoryフラグを設定するときに

class App : Application 
{ 
    public App() 
    { 
     MainPage = new MySplashPage(); 
    } 
} 

class MySplashPage : ContentPage 
{ 
    public MySplashPage() 
    { 
     Task.Delay(3000); //show my pretty splash for 3 seconds 
     Application.Current.MainPage = new MyOtherSpiffyPage(); 
    } 
} 
関連する問題