1

I would like know how to implement the Login Check example by comparing the username and password on Server-side using Web-Services in Android.

Community
  • 1
  • 1
Haresh Chaudhary
  • 4,390
  • 1
  • 34
  • 57

3 Answers3

2

A Complete Example for Authentication is Here

Ajay
  • 4,850
  • 2
  • 32
  • 44
  • 1
    it was a good example my dear friend....but i still has little problem and that too i will tell you tommorow..thanks a lot – Haresh Chaudhary Feb 13 '12 at 12:57
  • 1
    I am not able to access the webservice which is kept on my local PC's Apache server..can you give a tutorial for that...providing the url that we would use for our local host...i am unable to connect the server at all..please help me.. thanking you in advance.. – Haresh Chaudhary Feb 14 '12 at 07:05
  • i think you have problem with url – Ajay Feb 14 '12 at 07:09
  • you have to hit a proper url to get proper response – Ajay Feb 14 '12 at 07:09
  • Suppose..i have a php file(check.php) that returns 1 or 0 according to the username and password then how should i call that file...which url should be provided here.. response = CustomHttpClient.executeHttpPost("whichurl??",postParameters); Should it be like "http://localhost/haresh/check.php"........??? – Haresh Chaudhary Feb 14 '12 at 07:14
  • Exactly the same url "localhost/haresh/check.php" and parameters are username and password – Ajay Feb 14 '12 at 07:35
  • Yes Ajay...i have done exactly that you told above...but it gives an error that org.apache.http.conn. HttpHostConnectException:Connection to http://localhost refused – Haresh Chaudhary Feb 14 '12 at 10:27
  • Andriod emulator is separate virtual machine by itself. If we provide localhost/127.0.0.1 as a hostname, then emulator will try to search url within its environment. To avoid this problem, we need to provide the ipaddress of local machine. Pls note that machine name as a hostname will also give problem. – Ajay Feb 14 '12 at 10:32
  • there is post which helps you http://stackoverflow.com/questions/18617/how-do-you-configure-tomcat-to-bind-to-a-single-ip-address-localhost-instead-o for above comment's work – Ajay Feb 14 '12 at 10:36
  • 1
    Hey Ajay...i have done it...we should use the ip address that we get in cmd by ipconfig....i m able to pass the data to the php file...from their i insert it into the database of the server... But the problem goes on Extending... I return 1 from that php file...when i print the return value that i get in the android TextView by setText()..i get the all html syntaxs..but not the return value 1....Now how would i know that the user is authenticated or not in the java file ..?? And thankyou so much for your time...regards...buddy – Haresh Chaudhary Feb 14 '12 at 11:47
  • I have done it like this..... response = CustomHttpClient.executeHttpPost("http://192.168.1.134/haresh/check.php", postParameters); – Haresh Chaudhary Feb 14 '12 at 11:49
0

Use HttpPostmethod to check login. This will make the login secured.

Pattabi Raman
  • 5,814
  • 10
  • 39
  • 60
0

you can also check out Parse.io , the service will handle most of the server-side for you, depending on what you actually want to do.

zrgiu
  • 6,200
  • 1
  • 33
  • 35