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&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&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&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&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&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&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&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&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&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&action=themes:system:images:icon_siga.gif"alt="" border="0"></span><span class="caption"> SIGA - Sistema Integrado de Gest?o Acad?mica </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&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&action=html:images:lock.png"alt="" border="0"></span><span class="caption">Acesso ao Sistema </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á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.