【问题标题】:Implementing Childbrowser in Sencha Touch using Phone Gap使用 Phone Gap 在 Sencha Touch 中实现 Childbrowser
【发布时间】:2013-04-29 13:08:55
【问题描述】:

我目前正在为 Sencha Touch 2 中的 Android 操作系统进行部署。

我已在 app.json 文件中包含“cordova-2.2.0.js”、“ChildBrowser.js”的路径

我正在使用 Chrome 浏览器在 Windows PC 上开发它,并使用 Sencha 工具和 phonegap build 部署到 android 设备。

我的示例代码是

window.plugins.childBrowser.openExternal("http://www.google.com");

我的 webkit 浏览器出现以下错误。

Uncaught TypeError: Object # has no method 'exec'

在我的原生应用中,我没有得到任何响应。

请帮助...我正在包含我的 Main.js 文件

谢谢

Main.js 文件

Ext.define('Children.view.Main', {
extend: 'Ext.tab.Panel',
xtype: 'main',
requires: [
    'Ext.TitleBar',
    'Ext.Video'
],
config: {
    tabBarPosition: 'bottom',

    items: [
        {
            title: 'Welcome',
            iconCls: 'home',

            styleHtmlContent: true,

            items: [
                        {
                            xtype: 'button',
                            text: 'Open Google',
                            handler: function(button) {

                                         window.plugins.childBrowser.openExternal('http://www.google.com');
                            }
                        }

                    ]
        },
        {
            title: 'Get Started',
            iconCls: 'action',

            items: [
                {
                    docked: 'top',
                    xtype: 'titlebar',
                    title: 'Getting Started'
                },
                {
                    xtype: 'video',
                    url: 'http://av.vimeo.com/64284/137/87347327.mp4?token=1330978144_f9b698fea38cd408d52a2393240c896c',
                    posterUrl: 'http://b.vimeocdn.com/ts/261/062/261062119_640.jpg'
                }
            ]
        }
    ]
}

});

【问题讨论】:

    标签: javascript android cordova extjs


    【解决方案1】:

    这简直是一个很大很大很大的问题: 为此,您需要几项技术技能:javascript、sencha touch、java(适用于 Android 操作系统)和 phonegap 插件 你能写一个phonegap插件吗? 一个简短的收据,但我不包括 Java 代码,因为我需要你提供更多详细信息:

    • 在 res/xml 下的 config.xml 中放置你的插件配置(InfoP 是一个 Java 类):

    • 在您的 src 文件夹中添加 InfoPlugin.java;

    • 在 assets/www 下添加 infopl.js; (infopl.js 是调用 Java 插件的 javascript)

    • 在 index.html 中(例如)插件:

    在webapp中你可以调用插件:

    <script type="text/javascript">
    
      document.addEventListener('deviceready', function() {
    
          window.plugins.infoPl.getInfo(
               function(info) {
    
                    alert(info);
               //( you can see what you log on console with ADB console log)
                    console.log('MYINFO: '+info); 
               }, function() {
                   console.log("fail");
               }
           );
    
      }, false );
    </script>
    

    在 Sencha 中使用(如果您使用带有 sencha touch 的 MVC 功能的控制器会更好):

      listeners: {
        tap:
         function() {
            alert('something');
        }
    

    代替:

    handler: function(button) {
      alert('something');
    
    }
    

    建议你检查一下:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-15
      • 1970-01-01
      • 1970-01-01
      • 2012-09-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多