Hello,
I am developing a Xamarin android app for SharePoint. I am using the WebView control to show a SharePoint Modern Site. All link are working well, but the Highlight Content Webpart Links, is not working. In my code I have the following. Any suggestions ?
public class MainActivity : AppCompatActivity
{
EditText txtNavega;
WebView explorer;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
Button btnNavegar = FindViewById<Button>(Resource.Id.button1);
btnNavegar.Click += BtnNavegar_Click;
txtNavega = FindViewById<EditText>(Resource.Id.editText1);
explorer = FindViewById<WebView>(Resource.Id.webView1);
explorer.SetWebViewClient(new ExtendWebViewClient());
explorer.Settings.JavaScriptEnabled = true;
explorer.Settings.AllowContentAccess = true;
explorer.Settings.AllowFileAccess = true;
explorer.Settings.AllowFileAccessFromFileURLs = true;
explorer.Settings.AllowUniversalAccessFromFileURLs = true;
explorer.Settings.JavaScriptCanOpenWindowsAutomatically = true;
explorer.Settings.LightTouchEnabled = true;
explorer.Settings.SafeBrowsingEnabled = false;
}
private void BtnNavegar_Click(object sender, System.EventArgs e)
{
explorer.LoadUrl(txtNavega.Text);
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
internal class ExtendWebViewClient : WebViewClient
{
public override bool ShouldOverrideUrlLoading(WebView view, string url)
{
view.LoadUrl(url);
return true;
}
public override void OnUnhandledInputEvent(WebView view, InputEvent e)
{
base.OnUnhandledInputEvent(view, e);
}
// override
}
}