Android metaio AREL在应用程序中启动url,而不是外部浏览器

Android metaio AREL在应用程序中启动url,而不是外部浏览器,android,webview,arel,metaio,Android,Webview,Arel,Metaio,这是基于Metaio sdk的,但不确定问题是否取决于它。我使用Creator创建了一个基于AREL的Android应用程序。在检测到标记时,我想在webview中加载url 但是,当检测到标记时,我会得到一个对话框,选择在哪个浏览器中打开url 我如何覆盖它并在我的应用程序的webview中打开它 我尝试使用公共布尔shouldOverrideUrlLoading(WebView视图,字符串url),但没有调用它 如何确保获取活动试图打开的所有URL?这样我就可以将调用定向到webview 在

这是基于Metaio sdk的,但不确定问题是否取决于它。我使用Creator创建了一个基于AREL的Android应用程序。在检测到标记时,我想在webview中加载url

但是,当检测到标记时,我会得到一个对话框,选择在哪个浏览器中打开url

我如何覆盖它并在我的应用程序的webview中打开它

我尝试使用公共布尔shouldOverrideUrlLoading(WebView视图,字符串url),但没有调用它

如何确保获取活动试图打开的所有URL?这样我就可以将调用定向到webview

在我的活动中,我在onCreate中包含以下内容:

mWebView=(WebView)findViewById(R.id.WebView); setWebViewClient(新的WebViewHandler())

而这个外部onCreate:

类WebViewHandler扩展了WebViewClient {


您的覆盖有错误。您应该在
shouldOverrideUrlLoading()
的末尾返回
false
。这将允许您的WebView处理请求,而不是系统。

您是否尝试使用AREL.Media.openWebsite(url,false)在AREL中直接执行此操作


您可以直接从creator编辑arel代码

我通过覆盖ARELInterpreterCallback中的openWebsite()解决了这个问题,如下所示

//ARELViewActivity.java
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;

    import com.metaio.cloud.plugin.view.WebViewActivity;
    import com.metaio.sdk.ARELActivity;
    import com.metaio.sdk.jni.IARELInterpreterCallback;


    public class ARELViewActivity extends ARELActivity {

        protected ARELInterpreterCallback myARELCallback;

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            myARELCallback = new ARELInterpreterCallback();

            if (mARELInterpreter != null)
                mARELInterpreter.registerCallback(myARELCallback);
        }

        @Override
        protected int getGUILayout() {
            return 0;
        }

        class ARELInterpreterCallback extends IARELInterpreterCallback
        {

            @Override
            public void onSDKReady()
            {
                loadARELScene();
            }

            @Override
            public boolean openWebsite(String url, boolean openInExternalApp){

                //url is set with arel.Media.openWebsite("template://item#", false); inside logic.js
                if (url.contains("template://")) {
                    if (url.contains("item1")) {
                        urlSub = url.substring(14, url.length());
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Intent i = new Intent(ARELViewActivity.this, WebViewActivity.class);
                                i.putExtra(getPackageName() + ".URL", "http://www.google.com.mx");
                                startActivity(i);
                            }
                        });

                        return true;

                    } else {
                        urlSub = url.substring(14, url.length());
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Intent i = new Intent(ARELViewActivity.this, WebViewActivity.class);
                                i.putExtra(getPackageName() + ".URL", "http://www.yahoo.com.mx");
                                startActivity(i);
                            }
                        });

                        return true;
                    }

                } else {
                    return false;
                    //return super.openWebsite(url, openInExternalApp);
                }

            }
        }

    }

基于某些条件,它返回true/false。我没有粘贴到这里。问题是我没有得到日志“触发url”,所以根本没有调用它,对吗?发布你的条件的基本内容,并添加一些小注释进行解释。我删除了所有内容,只留下Log.d*(),返回:false inside shouldOverrideUrlLoading()但仍然没有。它没有被调用…我缺少什么?您是否记得设置webview以从shouldOverride…方法加载url?
//ARELViewActivity.java
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;

    import com.metaio.cloud.plugin.view.WebViewActivity;
    import com.metaio.sdk.ARELActivity;
    import com.metaio.sdk.jni.IARELInterpreterCallback;


    public class ARELViewActivity extends ARELActivity {

        protected ARELInterpreterCallback myARELCallback;

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);

            myARELCallback = new ARELInterpreterCallback();

            if (mARELInterpreter != null)
                mARELInterpreter.registerCallback(myARELCallback);
        }

        @Override
        protected int getGUILayout() {
            return 0;
        }

        class ARELInterpreterCallback extends IARELInterpreterCallback
        {

            @Override
            public void onSDKReady()
            {
                loadARELScene();
            }

            @Override
            public boolean openWebsite(String url, boolean openInExternalApp){

                //url is set with arel.Media.openWebsite("template://item#", false); inside logic.js
                if (url.contains("template://")) {
                    if (url.contains("item1")) {
                        urlSub = url.substring(14, url.length());
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Intent i = new Intent(ARELViewActivity.this, WebViewActivity.class);
                                i.putExtra(getPackageName() + ".URL", "http://www.google.com.mx");
                                startActivity(i);
                            }
                        });

                        return true;

                    } else {
                        urlSub = url.substring(14, url.length());
                        runOnUiThread(new Runnable() {
                            @Override
                            public void run() {
                                Intent i = new Intent(ARELViewActivity.this, WebViewActivity.class);
                                i.putExtra(getPackageName() + ".URL", "http://www.yahoo.com.mx");
                                startActivity(i);
                            }
                        });

                        return true;
                    }

                } else {
                    return false;
                    //return super.openWebsite(url, openInExternalApp);
                }

            }
        }

    }