Software Archive
Read-only legacy content
17061 Discussions

It does not work on Android but intelXDK APP Preview works well

Marcelo_Cabral
Beginner
1,455 Views

 

Hello gentlemen, good night!

I have a big problem, then tested and approved by the APP and Emulator Preview APP,

I generated the apk and published. But when we install on Android device, nothing works!

The screens do not go down right and AJAX function does not roll!

I also have a function that calls sending email OS. This works well in the Preview APP and the email is sent.

But the cell he did not call the Email screen!

Squeeze the buttons and nothing happens.

I'm using Materialize JQuery AJAX JavaScript PHP and MySQL.

Could anyone help me with this problem? I'm almost going to the native development due to this problem. Go through it with a customer is at least frustrating.

Thanks already!

 

0 Kudos
9 Replies
Hamilton_Tenório_da_
Valued Contributor I
1,455 Views

Are you using PHP and MySQL in the app? This do not work on webapp.

0 Kudos
Swati_S_Intel1
Employee
1,455 Views

Can you capture the AJAX error and send me? If possible send your project  via PM.

0 Kudos
Marcelo_Cabral
Beginner
1,455 Views

How can send a project?

0 Kudos
Marcelo_Cabral
Beginner
1,455 Views

  i received a console message

  No Content-Security-Policy meta tag found.

Please add one when using the cordova-plugin-whitelist plugin.

 

0 Kudos
Anusha_M_Intel1
Employee
1,455 Views

Marcelo, the cordova whitelist plugin is added when the app is built. Can you also go to plugin management in the projects tab and check if it shows that the whitelist plugin is added. If so, remove it.

Your issue will be resolved if you add meta tags. Read this for more info: https://github.com/apache/cordova-plugin-whitelist#content-security-policy

 

0 Kudos
Marcelo_Cabral
Beginner
1,455 Views

 Intel XDK have

intelxdk.config.additions.xml

intelxdk.config.android.app.xml

intelxdk.config.android.xml

intelxdk.config.crosswalk.xml

intelxdk.config.ios.xml

intelxdk.config.windows8.xml

intelxdk.config.wp81.xml

 

In which files put the Navigation Whitelist ( <allow-navigation href="http://*/*" /> ) ...  all?

 

0 Kudos
Marcelo_Cabral
Beginner
1,455 Views

Hello, I got some progress, but I am now getting to the status 0 of ajax request ...

the responseText is the JSON I want, just right, but the status is 0 and falls in  .fail (function (jqXHR, status, error) ...

i research here but it's a little complicated this happened ...

my code

(function(){
    "use strict";
    function evento(){
        $(document).on("click", "#btnEfetuarLogin", function(e){
           e.preventDefault();  

           loading("Buscando usuário...");
            $("#listaDeMensagens").empty();
            $("#situacao").html(""); 
            
            var login = $("#txtUsuario").val();
            var senha = $("#txtSenha").val();
            var url   = "http://www.mysite.com.br/projetos/api/login/" + login + "/" + senha ;       
            
            //AJAX 
            $.ajax({
                type: 'GET',
                url:  url,
                contentType: "application/json; charset=utf-8",
                crossDomain: true,   
                async: false
            }).done(function(result, jqXHR){
                var arr    = JSON.parse(result);
                var logado = 0;
                
                $.each(arr, function(i, usu){           
                    intel.xdk.cache.setCookie("cod_usuario"  , usu.cod_usuario  , 7);
                    intel.xdk.cache.setCookie("nome"         , usu.nome         , 7);
                    intel.xdk.cache.setCookie("tipo_usuario" , usu.tipo_usuario , 7);
                    intel.xdk.cache.setCookie("vencimento"   , usu.vencimento   , 7);
                    intel.xdk.cache.setCookie("tel"          , usu.tel          , 7);
                    intel.xdk.cache.setCookie("email"        , usu.email        , 7);
                    logado = i + 1;
                });
                if(logado > 0 ){

                    carregarMinhasMensagens();
                    carregarAlunos();
                    carregarMensagensGravadas();
                    carregarPerfilUsuarioLogado();
                    evtCarregarMsg();

                    
                    //Zerar campos do login
                    $("#formLogin").each(function(){ this.reset(); });
                    
                    $("#tituloAbaMinhasMsg").html("&nbsp;Olá, " + (intel.xdk.cache.getCookie("nome").split(" ")[0]) );

                    $.mobile.changePage("#pgHome", "slideup");
                    //Materialize.showStaggeredList('#listaDeMensagens');
                    
                    filtrarTabs();
                    
                    $("#situacao").html("Acesso concedido.");
                    situacaoSucesso("situacao"); 
                    
                } else {
                    $("#situacao").html("<p>Usuário não encontrado ou senha inválida.</p>");
                    situacaoFalha("situacao");
                }
                
            }).fail(function(jqXHR, status, error){

               $("#situacao").html("<p>Falha na transação: </p><p>" + jqXHR.status + "</p><p>Data: " + url + "</p>");

                situacaoFalha("situacao");

            }).complete(function(){
                $.mobile.loading( "hide" );
            });
            //FIM AJAX
            return false;
        });
    }
    
    function loading(acao){
        // FUNÇÃO LOADING...
           var $this = $( this ),
                theme       = $this.jqmData( "theme" )       || $.mobile.loader.prototype.options.theme,
                // msgText     = $this.jqmData( "msgtext" )     || $.mobile.loader.prototype.options.text,
                textVisible = $this.jqmData( "textvisible" ) || $.mobile.loader.prototype.options.textVisible,
                textonly    = !!$this.jqmData( "textonly" );
            $.mobile.loading( "show", {
                text: acao,
                textVisible: true,
                theme: theme,
                textonly: textonly
            });
            // FIM FUNÇÃO LOADING..
    }

    function carregarPerfilUsuarioLogado(){
        $("#lblNomeUsuarioLogado").html("<CENTER>"  + intel.xdk.cache.getCookie("nome")  + "</CENTER>");
        $("#lblTelUsuarioLogado").html("<CENTER>"   + intel.xdk.cache.getCookie("tel")   + "</CENTER>");
        $("#lblEmailUsuarioLogado").html("<CENTER>" + intel.xdk.cache.getCookie("email") + "</CENTER>");
        esconderAlterarSenha();
    }

    function evtCarregarMsg(){
        $("#listaDeMensagens").on("click", "li", function(){

            var id    = $(this).attr('data-id');
            var dados = JSON.parse(intel.xdk.cache.getCookie("mensagens"));
            var nome;
            var msgem;
            var usuEnvio;
            var usuDestino;
            var dataEnvio;

            $.each(dados, function(i, m){
                if(m.cod_envio == id){
                    nome       = m.nome;
                    msgem      = m.mensagem;
                    usuEnvio   = m.usuEnvio;
                    usuDestino = m.usuDestino;
                    dataEnvio  = m.data_envio;
                }        
            });

            $("#pgMsg #lblUsuEnvio").html(usuEnvio);
            $("#pgMsg #lblMsg").html(msgem);
            $("#pgMsg #lblDataEnvio").html(dataEnvio);

            $.mobile.changePage("#pgMsg");
            marcarMsgComoLida(id);

        });

    }

    document.addEventListener("app.Ready", evento, false);    

})();

0 Kudos
Tawab_G_
Beginner
1,454 Views

I have the same problem, JS XMLhttprequest works in emulator AND iOS, however when testing on android OR windows phone it doesnt work. (no errors, it just wont do anything)

Let me know if you've found a fix. 

0 Kudos
PaulF_IntelCorp
Employee
1,454 Views

Please see this FAQ > https://software.intel.com/en-us/xdk/faqs/app-designer#ajax-jquery-one-fail < it is likely the reason for your AJAX problems.

0 Kudos
Reply