简体   繁体   English

如何从android apk在浏览器中打开网页?

[英]How to open web page in browser from android apk?

I created a simple app with Sencha Architect and pack it to .apk. 我用Sencha Architect创建了一个简单的应用程序,并将其打包到.apk中。 When I test it on my device, i notice that I couldn't switch to browser and open a web page from the app. 在设备上对其进行测试时,我注意到无法切换至浏览器并无法从该应用程序打开网页。
(eg the app show a yes-no dialog, when user press the yes button it should switch to browser and open certain url) (例如,应用显示“是-否”对话框,当用户按下“是”按钮时,应切换到浏览器并打开某些网址)

Here is the code that I use: 这是我使用的代码:

Ext.Msg.confirm(
        "Confirmation", // Title
        "Please tap yes to google in web browser.", // Message
        function (btn) {
            if (btn === 'yes') {
                //Ext.Msg.alert("You have selected Yes", "");
                // This should opening the web page on that can be used to connect to facebook from server //
                Ext.device.Device.openURL('http://www.google.com');
            }
            else {
                //Ext.Msg.alert("NO", "You have selected NO");
            }
        },
        this
        );

It working when I tested it in a browser, but not working when I packed it to apk with sencha cmd. 当我在浏览器中对其进行测试时,它可以正常工作,但是当我使用sencha cmd将其打包为apk时,它就无法工作。 Does anyone can help me with this? 有人可以帮我吗? Thanks in advance. 提前致谢。

It has some issues in the version 2.1B2. 在2.1B2版本中存在一些问题。

This will work with the next version of the Native Packager which is going in with Beta 3.    -
Jamie Avins  
Sencha - Sencha Touch Dev Team

Link to Forum 链接到论坛

I think that mistake is there: If (btn = = = yes), there is not === but == . 我认为这里存在错误:如果(btn = = =是),则不是===,而是==。 Try it.. 试试吧..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM