如何使用cordova将我的bootstrap mvc网站转换为Android应用程序

时间:2018-06-11 13:04:08

标签: android cordova web-applications

如何使用cordova将我的bootstrap .net mvc网站转换为Android应用程序。 我在我的托管网络应用程序网址上使用了下面的cordova index.js文件。 我还在配置文件中添加了allow-navigation标签。  我在安装应用程序后成功生成apk文件我看到空屏

  var app = {
 // Application Constructor
  initialize: function() {
    document.addEventListener('deviceready', this.onDeviceReady.bind(this), 
  false);
 },

onDeviceReady: function() {
    this.receivedEvent('deviceready');

    if (navigator.network.connection.type == Connection.NONE) {
        networkError()
      } else {
        loadApp()
      }
},
 loadApp:function() {

   navigator.app.loadUrl("%my web application url%")
  },

   networkError:function() {
    navigator.notification.alert('requires an internet connection')
    var $net = document.createElement('div')
    $net.innerHTML = 'requires an internet connection'
    document.body.appendChild($net)
  },

// Update DOM on a Received Event
receivedEvent: function(id) {
    var parentElement = document.getElementById(id);
    var listeningElement = parentElement.querySelector('.listening');
    var receivedElement = parentElement.querySelector('.received');

    listeningElement.setAttribute('style', 'display:none;');
    receivedElement.setAttribute('style', 'display:block;');

    console.log('Received Event: ' + id);
 }
};

app.initialize();

0 个答案:

没有答案