alert dialog from javascript not appear in xamarin crosswalk webview

jomart mirza
jomart mirza used Ask the Experts™
on
how to show java-script alerts and HTML dialog input in Xamarin crosswalk ????
its working by default when using crosswalk in android studio ..
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Zakaria AcharkiAnalyst Developer
Distinguished Expert 2018

Commented:
Setting the WebChromeClient is needed to get the alert() , try set it like :

mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.setWebChromeClient(new WebChromeClient());

Open in new window


Take a look at this discussion, It may be helpful in your case :

https://issuetracker.google.com/issues/36905249

Author

Commented:
yes this is for  built-in web view  but for crosswalk web view alert not working by default in Xamarin  like android studio i search google a lot didn't find anything it had to be some solution
Zakaria AcharkiAnalyst Developer
Distinguished Expert 2018

Commented:
Ok, I see, could you please share with as the relevant part of your code.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
sure this is what i tried :

using Android.App;
using Android.Widget;
using Android.OS;
using System;
using Android.Views;
using Android.Content.Res;
using System.IO;

using Android.Util;
using Android.Content;
using System.Threading;
using System.Threading.Tasks;
using System.Text;
using System.Text.RegularExpressions;
using Org.Xwalk.Core;

namespace XWalk
{
    [Activity(Label = "XWalk", MainLauncher = true)]
    public class MainActivity : XWalkActivity
    {

        public static Activity fa;
        public Org.Xwalk.Core.XWalkView xwv;

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
        }

        protected override void OnXWalkReady()
        {
            fa = this;

            var view = new RelativeLayout(this.BaseContext);
            var mp = ViewGroup.LayoutParams.MatchParent;
            xwv = new Org.Xwalk.Core.XWalkView(this.BaseContext, this);
            view.AddView(xwv);
            this.AddContentView(view, new ViewGroup.LayoutParams(mp, mp));
            XWalkPreferences.SetValue("enable-javascript", true);
            xwv.SetResourceClient(new XWalkResourceClient(xwv));\\ this code should work
            xwv.SetUIClient(new XWalkUIClient(xwv));\\or this
            xwv.LoadUrl("file:///android_asset/index.html");
   
        }
}
}

but its not working ..
Zakaria AcharkiAnalyst Developer
Distinguished Expert 2018

Commented:
Could you check if the JS is enabled using "getJavaScriptEnabled()" and make sure there's no message error logged.

Author

Commented:
JavaScript is enabled by default and i test it in other js function and its working  but the alert function and anything need dialog is not appears  so i even hired some one to find me an answer and i'm still waiting because i really supersized that i didn't find any easy solution for this issue

Author

Commented:
when i press  this HTML component it should give me dialog :

 <select>
            <option value="volvo">Volvo</option>
            <option value="saab">Saab</option>
            <option value="mercedes">Mercedes</option>
            <option value="audi">Audi</option>
        </select>


i get this in log output :

01-16 12:07:42.117 V/BoostFramework( 5609): BoostFramework() : mPerf = com.qualcomm.qti.Performance@48196b1
01-16 12:07:42.117 D/HwCust  ( 5609): Create obj success use class android.widget.HwCustTextViewImpl
01-16 12:07:42.127 D/HwCust  ( 5609): Create obj success use class android.widget.HwCustTextViewImpl
01-16 12:07:42.127 D/HwCust  ( 5609): Create obj success use class android.widget.HwCustTextViewImpl
01-16 12:07:42.137 D/HwCust  ( 5609): Create obj success use class android.widget.HwCustTextViewImpl
01-16 12:07:42.147 E/Dialog  ( 5609): show mWindowManager.addView RuntimeException

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial