Login screen on Android

2

I emulated a local server for XAMPP and started trying to develop a login screen for an Android application.

It is working perfectly, but only when I log in to the localhost (using my local IP address instead of localhost, because the AVD makes the access as if the server was online) and entering with the login and password already pre-defined. I want to make the login validated by visiting the following page: link .

Can I make it work by modifying only part of the code below? Does the fact that the system is made using the MIOLO framework affect anything?

btAcessar.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        Log.i("Logar", "Entrou no evento");
        String urlPost="http://localhost/android/logar.php";
        String urlGet="http://localhost/android/logar.php?usuario="+etUsuario.getText().toString()+"&senha="+etSenha.getText().toString();
        ArrayList<NameValuePair> parametrosPost = new ArrayList<NameValuePair>();
        parametrosPost.add(new BasicNameValuePair("usuario", etUsuario.getText().toString()));
        parametrosPost.add(new BasicNameValuePair("senha", etSenha.getText().toString()));
        String respostaRetornada = null;
        Log.i("Logar", "Vai entrar no try");

        try{
            respostaRetornada = ConexaoHttpClient.executaHttpPost(urlPost, parametrosPost);
            //respostaRetornada = ConexaoHttpClient.executaHttpGet(urlGet);
            String resposta = respostaRetornada.toString();
            Log.i("Logar", "resposta = "+resposta);
            resposta = resposta.replaceAll("\s+", "");
            if(resposta.equals("1"))
                startActivity(new Intent(Logar.this, MenuPrincipal.class));
                //mensagemExibir("Login", "Usuário Válido.");
            else
                mensagemExibir("Login", "Usuário Iválido.");
        }
        catch(Exception erro){
            Log.i("Erro", "erro = "+erro);
            Toast.makeText(Logar.this, "Erro.: "+erro, Toast.LENGTH_LONG);
        }
    }
});

What changes will it take for me to move on?

LogCat report of when I replace the localhost with the address link :

10-09 12:54:09.709: I/Logar(930): Entrou no evento
10-09 12:54:09.709: I/Logar(930): Vai entrar no try
10-09 12:54:09.969: I/logar(930): resposta = <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
10-09 12:54:09.969: I/logar(930): <html>
10-09 12:54:09.969: I/logar(930): <head>
10-09 12:54:09.969: I/logar(930): <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
10-09 12:54:09.969: I/logar(930): <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1" />
10-09 12:54:09.969: I/logar(930): <title>SIGA :: UFVJM</title>
10-09 12:54:09.969: I/logar(930): <link rel="shortcut icon" href="http://siga.ufvjm.edu.br/images/icon_siga.gif" />
10-09 12:54:09.969: I/logar(930): <link rel="stylesheet" type="text/css" href="http://siga.ufvjm.edu.br/index.php?module=miolo&amp;action=themes:system:m_themeelement.css">
10-09 12:54:09.969: I/logar(930): <link rel="stylesheet" type="text/css" href="http://siga.ufvjm.edu.br/index.php?module=miolo&amp;action=themes:system:m_controls.css">
10-09 12:54:09.969: I/logar(930): <link rel="stylesheet" type="text/css" href="http://siga.ufvjm.edu.br/index.php?module=miolo&amp;action=themes:system:m_forms.css">
10-09 12:54:09.969: I/logar(930): <link rel="stylesheet" type="text/css" href="http://siga.ufvjm.edu.br/index.php?module=miolo&amp;action=themes:system:m_common.css">
10-09 12:54:09.969: I/logar(930): <link rel="stylesheet" type="text/css" href="http://siga.ufvjm.edu.br/index.php?module=miolo&amp;action=themes:system:m_boxes.css">
10-09 12:54:09.969: I/logar(930): <link rel="stylesheet" type="text/css" href="http://siga.ufvjm.edu.br/index.php?module=miolo&amp;action=themes:system:forms.css">
10-09 12:54:09.969: I/logar(930): <link rel="stylesheet" type="text/css" href="http://siga.ufvjm.edu.br/index.php?module=miolo&amp;action=themes:system:tabelas.css">
10-09 12:54:09.969: I/logar(930): <link rel="stylesheet" type="text/css" href="http://siga.ufvjm.edu.br/index.php?module=miolo&amp;action=themes:system:siga.css">
10-09 12:54:09.969: I/logar(930): <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
10-09 12:54:09.969: I/logar(930): <meta name="Generator" content="MIOLO Version Miolo 2.0 beta1; http://www.miolo.org.br">
10-09 12:54:09.969: I/logar(930): <script type="text/javascript" src="http://siga.ufvjm.edu.br/scripts/prototype/prototype.js"></script>10-0912:54:09.969:I/logar(930):<scripttype="text/javascript" src="http://siga.ufvjm.edu.br/scripts/m_miolo.js"></script>10-0912:54:09.969:I/logar(930):<scripttype="text/javascript" src="http://siga.ufvjm.edu.br/scripts/m_compatibility.js"></script>10-0912:54:09.969:I/logar(930):<scripttype="text/javascript" src="http://siga.ufvjm.edu.br/scripts/m_form.js"></script>10-0912:54:09.969:I/logar(930):<scripttype="text/javascript">
10-09 12:54:09.969: I/logar(930): miolo.onSubmit = function ()
10-09 12:54:09.969: I/logar(930): {
10-09 12:54:09.969: I/logar(930):     this.submit();
10-09 12:54:09.969: I/logar(930):     return true;
10-09 12:54:09.969: I/logar(930): }
10-09 12:54:09.969: I/logar(930): window.onload = function () {
10-09 12:54:09.969: I/logar(930): MIOLO_GetElementById('uid').focus();
10-09 12:54:09.969: I/logar(930):    miolo.setTitle('SIGA :: UFVJM');
10-09 12:54:09.969: I/logar(930): miolo.setForm('frm543685723f9db');
10-09 12:54:09.969: I/logar(930): form_frm5436857246321 = new Miolo.form('frm5436857246321');
10-09 12:54:09.969: I/logar(930): }
10-09 12:54:09.969: I/logar(930): //-->
10-09 12:54:09.969: I/logar(930): </script>
10-09 12:54:09.969: I/logar(930): </head>
10-09 12:54:09.969: I/logar(930): <body class="m-theme-body">
10-09 12:54:09.969: I/logar(930): <form id="frm543685723f9db" name="frm543685723f9db" method="post" action="http://siga.ufvjm.edu.br/index.php?module=common&amp;action=main"  onSubmit="return miolo.onSubmit();" > 
10-09 12:54:09.969: I/logar(930): <div id="m-container">
10-09 12:54:09.969: I/logar(930): <div id="m-container-top">
10-09 12:54:09.969: I/logar(930): <div class="m-box-title"><span class="icon">
10-09 12:54:09.969: I/logar(930): <img src="http://siga.ufvjm.edu.br/index.php?module=miolo&amp;action=themes:system:images:icon_siga.gif"alt="" border="0"></span><span class="caption">&nbsp;SIGA&nbsp;-&nbsp;Sistema&nbsp;Integrado&nbsp;de&nbsp;Gest?o&nbsp;Acad?mica&nbsp;&nbsp;</span></div></div>
10-09 12:54:09.969: I/logar(930): <div id="m-container-module">
10-09 12:54:09.969: I/logar(930): <div id="m_m4" class="m-module-header"></div></div>
10-09 12:54:09.969: I/logar(930): <div id="m-container-content-full">
10-09 12:54:09.969: I/logar(930): <div style="float:left;margin-right:5px">
10-09 12:54:09.969: I/logar(930): <img src="http://siga.ufvjm.edu.br/index.php?module=miolo&amp;action=themes:system:images:logo_siga.jpg"alt="Home" border="0"></div>
10-09 12:54:09.969: I/logar(930): <div style="width:650px;float:left;margin-right:5px">
10-09 12:54:09.969: I/logar(930): <div id="frm5436857246321" class="m-form-box">
10-09 12:54:09.969: I/logar(930): <div id="m10" class="m-box-outer m-form-outer">
10-09 12:54:09.969: I/logar(930): <div class="m-box-box">
10-09 12:54:09.969: I/logar(930): <div class="m-box-title"><span class="icon">
10-09 12:54:09.969: I/logar(930): <img src="http://siga.ufvjm.edu.br/index.php?module=common&amp;action=html:images:lock.png"alt="" border="0"></span><span class="caption">Acesso&nbsp;ao&nbsp;Sistema&nbsp;&nbsp;</span></div>
10-09 12:54:09.969: I/logar(930): <div class="m-form-body">
10-09 12:54:09.969: I/logar(930): <div>
10-09 12:54:09.969: I/logar(930): <div class="m-form-row"><span class="label" style="width:25%">
10-09 12:54:09.969: I/logar(930): <label  class="m-caption" for="uid">Usu&aacute;rio:</label></span><span class="field" style="width:70%">
10-09 12:54:09.969: I/logar(930): <input  type="text" id="uid" class="m-text-field" name="uid" value="" size="20"></span></div>
10-09 12:54:09.969: I/logar(930): <div class="m-form-row"><span class="label" style="width:25%">
10-09 12:54:09.969: I/logar(930): <label  class="m-caption" for="pwd">Senha:</label></span><span class="field" style="width:70%">
10-09 12:54:09.969: I/logar(930): <input  typ
10-09 12:54:10.099: D/dalvikvm(930): GC_FOR_ALLOC freed 236K, 13% free 2723K/3104K, paused 25ms, total 28ms
10-09 12:54:10.319: I/Choreographer(930): Skipped 54 frames!  The application may be doing too much work on its main thread.
    
asked by anonymous 03.10.2014 / 22:03

1 answer

2

Use Threads to do heavy jobs in your application, such as disk access, downloads, image processing, etc. read more. If you catch the main thread of the process, the application will receive a ANR . ie you can not lock the main thread for more than 5 seconds and in case of BroadsCast, not more than 10 seconds.

10-09 12:54:09.969: I/logar(930): <label  class="m-caption" for="pwd">Senha:</label></span><span class="field" style="width:70%">
10-09 12:54:09.969: I/logar(930): <input  typ
10-09 12:54:10.099: D/dalvikvm(930): GC_FOR_ALLOC freed 236K, 13% free 2723K/3104K, paused 25ms, total 28ms
10-09 12:54:10.319: I/Choreographer(930): Skipped 54 frames!  The application may be doing too much work on its main thread.

The server response is coming incomplete, probably because the process was interrupted for long time the main thread, as you said, using local server works perfectly isos why using local network (your machine) the response time is fast enough not to crash the main thread for long.

private class DownloadFilesTask extends AsyncTask<URL, Integer, Long> {
         protected Long doInBackground(URL... urls) {
             int count = urls.length;
             long totalSize = 0;
             for (int i = 0; i < count; i++) {
                 totalSize += Downloader.downloadFile(urls[i]);
                 publishProgress((int) ((i / (float) count) * 100));
                 // Escape early if cancel() is called
                 if (isCancelled()) break;
             }
             return totalSize;
         }

         protected void onProgressUpdate(Integer... progress) {
             setProgressPercent(progress[0]);
         }

         protected void onPostExecute(Long result) {
             showDialog("Downloaded " + result + " bytes");
         }
     }

To run the thread.

new DownloadFilesTask().execute(url1, url2, url3);
    
10.10.2014 / 15:18