我建立它採用網頁視圖中xamarin的應用程序,我已經測試了他們的許多設備,如銀河S7邊緣。我想其中的原因不工作是因爲邊緣網屏的。但是,它在S7 Edge上正常工作,但在我嘗試過的S8 Edge設備上,它們會立即崩潰。Android應用程序崩潰的銀河S8僅邊沿
有隻有兩個,我使用類:
MainActivity:
namespace APPNAME.Android
{
[Activity(Label = "APPNAME", Icon = "@drawable/icon", MainLauncher =
false,
ConfigurationChanges = ConfigChanges.ScreenSize |
ConfigChanges.Orientation)]
public class MainActivity : Activity
{
WebView web_view;
//private bool appeared;
public class HelloWebViewClient : WebViewClient
{
public override bool ShouldOverrideUrlLoading(WebView view, string
url)
{
view.LoadUrl(url);
return false;
}
}
protected override void OnCreate(Bundle bundle)
{
Window.RequestFeature(WindowFeatures.NoTitle);
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
web_view = FindViewById<WebView>(Resource.Id.webview);
web_view.Settings.JavaScriptEnabled = true;
web_view.SetWebViewClient(new HelloWebViewClient());
web_view.LoadUrl("http://link.com");
}
public override bool OnKeyDown(Keycode keyCode, KeyEvent e)
{
if (keyCode == Keycode.Back && web_view != null)
{
try
{
if (web_view.CanGoBack())
{
Log.Debug("StackOverflow", "Allow browser back");
// Toast.MakeText(this, "Going back",
ToastLength.Short).Show();
web_view.GoBack();
return true;
}
}
catch (Exception ex)
{
Log.Error("StackOverflow", ex.Message);
}
}
{
//Log.Error("StackOv20erflow", "Null webview...");
//StartActivity(typeof(MainActivity));
//Finish();
OnBackPressed();
}
//Log.Debug("StackOverflow", "Back button blocked");
//Toast.MakeText(this, "Back button blocked",
ToastLength.Short).Show();
return false;
}
public override void OnBackPressed()
{
Intent startMain = new Intent(Intent.ActionMain);
startMain.AddCategory(Intent.CategoryHome);
startMain.SetFlags(ActivityFlags.NewTask);
StartActivity(startMain);
}
}
}
閃屏:
namespace APPNAME.Android
{
[Activity(Theme = "@style/MyTheme.Splash", MainLauncher = true, NoHistory =
true)]
public class SplashActivity : AppCompatActivity
{
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();
Task startupWork = new Task(() => { SimulateStartup(); });
startupWork.Start();
}
// Simulates background work that happens behind the splash screen
async void SimulateStartup()
{
//Log.Debug(TAG, "Performing some startup work that takes a bit of
time.");
//await Task.Delay(1000); // Simulate a bit of startup work.
//Log.Debug(TAG, "Startup work is finished - starting
MainActivity.");
//StartActivity(new Intent(Application.Context,
typeof(MainActivity)));
await Task.Delay(4000);
var intent = new Intent(this, typeof(MainActivity));
intent.AddFlags(ActivityFlags.ClearTop | ActivityFlags.NewTask);
StartActivity(intent);
}
}
}
清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionName="1.0.0.8" package="APPNAME.android"
android:installLocation="auto" android:versionCode="8">
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="25" />
<application android:label="APPNAME" android:icon="@drawable/Icon"
android:debuggable="false"></application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
不知道從哪裏開始修復發行因爲我不知道這是什麼原因。
任何幫助,將不勝感激!
事件和處理程序請包括logcat的輸出也崩潰 –
什麼在Logcat中? – SushiHangover
您是否安裝了碰撞記者?如果沒有,請添加一個;-) – SushiHangover