
//abre la app
function openTheApp(){
  var APP = window.navigator.mozApps.getSelf();
   
  APP.onsuccess = function() {
    if (APP.result) {
        // Open the application 
        // FIXME If the device is blocked, the application won't open
        APP.result.launch();
        console.log('app abierta');
    } else {
      console.log("Called from outside of the app");
    }
  };
  // Handle the error
  APP.onerror = function() {
    alert("Error: " + request.error.name);
  };
}

//recoge el icono de la app
function getIcon(){

  var APP = window.navigator.mozApps.getSelf();
   
  APP.onsuccess = function() {
    if (APP.result) {
        // Open the application
        var icon = APP.result.manifest.icons['30'];
        console.log('Icon: '+APP.result.installOrigin+icon);
        return APP.result.installOrigin+icon;
    } else {
      console.log("Called from outside of the app");
    }
  };
  // Handle the error
  APP.onerror = function() {
    alert("Error: " + request.error.name);
  };
}
