2
I emulated a local server by XAMPP and started trying to develop a login screen for an Android application.
It is working perfectly, but only when I log in through localhost
(using my local IP address instead of the localhost, because AVD does the access as if the server were online) and entering the password and login already pre-defined. I want to make the login validated when accessing the following page: http://siga.ufvjm.edu.br/.
I can make it work by modifying only part of the code below? The fact that the system is done using the MIOLO Framework affects something?
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 be necessary for me to go ahead?
Logcat report when I replace localhost with address http://siga.ufvjm.edu.br/index.php?module=common&action=main:
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-09 12:54:09.969: I/logar(930): <script type="text/javascript" src="http://siga.ufvjm.edu.br/scripts/m_miolo.js"></script>
10-09 12:54:09.969: I/logar(930): <script type="text/javascript" src="http://siga.ufvjm.edu.br/scripts/m_compatibility.js"></script>
10-09 12:54:09.969: I/logar(930): <script type="text/javascript" src="http://siga.ufvjm.edu.br/scripts/m_form.js"></script>
10-09 12:54:09.969: I/logar(930): <script type="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.
You need to explain better what you need, but from what I understand, you want to log on to a website, right ? If yes, to begin with, the url you should try to make a post is http://siga.ufvjm.edu.br/index.php?module=common&action=main and the parameters are uid (login) and pwd (password).
– wryel
That’s exactly what I intend to do. I have tried to add this information in the code, both the link and the parameters, but not yet succeeded with only this data.
– Marlon Paranhos
It is interesting that you add the server answer to the question.
– Luídne
@Marpd144, is managing the
Cookies
? In general the system must keep a user session withCookies
.– Wakim
@Luídne, I’ll do it. Thank you. I may be messing around asking this, but the fact that the university system is made using the MIOLO Framework affects something?
– Marlon Paranhos
@Wakim, I’m not, I haven’t studied that part yet. Would it be essential for functioning? Thank you
– Marlon Paranhos
@Marpd114, yes it is paramount to manage the sending and receiving of cookies. Otherwise you may always receive an expired session message or without permission.
– Wakim
@Wakim, I will give a study on that part tbm. Thank you
– Marlon Paranhos
First detail IMPORTATE! ,
10-09 12:54:10.319: I/Choreographer(930): Skipped 54 frames! The application may be doing too much work on its main thread.
Use treads to do work in the application. one-night stand here.– Duanniston Cardoso Cabral