在Sencha Touch中使用Phone Gap实现儿童浏览器



我目前在Sencha Touch 2中部署Android操作系统

我已经在app.json文件中包含了"cordova-2.2.0.js","ChildBrowser.js"的路径

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

我的示例代码是

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

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

未捕获的TypeError: object#没有方法'exec'

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

Please Help…我正在包含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, sencha touch, java(适用于Android操作系统)和phonegap插件你会写一个phonegap插件吗?一个简短的收据,但我不包括Java代码,因为我需要更多的细节从你:

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

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

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

在web应用中,你可以调用插件:

<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');
}

您建议您检查:

  • http://docs.phonegap.com/en/2.6.0/guide_plugin-development_index.md.html插件% 20发展% 20指南

  • http://docs.sencha.com/touch/2.2.0/!/视频/mvc-part-1

最新更新