Tuesday, June 21, 2011

Android Login Screen Using HttpClient

I have updated this code to use web service and open new screen if the login is successful in my post Android Web Service Access Tutorial.

In Android we can use HTTP POST request with org.apache.http.client.HttpClient to post data to a URL. This sample project illustrate how we can post data to a URL and get the response.


package com.sencide;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class AndroidLogin extends Activity implements OnClickListener {
 
 Button ok,back,exit;
 TextView result;
 
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        // Login button clicked
        ok = (Button)findViewById(R.id.btn_login);
        ok.setOnClickListener(this);
        
        result = (TextView)findViewById(R.id.lbl_result);
        
    }
    
    public void postLoginData() {
        // Create a new HttpClient and Post Header
        HttpClient httpclient = new DefaultHttpClient();
        
        /* login.php returns true if username and password is equal to saranga */
        HttpPost httppost = new HttpPost("http://www.sencide.com/blog/login.php");

        try {
            // Add user name and password
         EditText uname = (EditText)findViewById(R.id.txt_username);
         String username = uname.getText().toString();

         EditText pword = (EditText)findViewById(R.id.txt_password);
         String password = pword.getText().toString();
         
            List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
            nameValuePairs.add(new BasicNameValuePair("username", username));
            nameValuePairs.add(new BasicNameValuePair("password", password));
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

            // Execute HTTP Post Request
            Log.w("SENCIDE", "Execute HTTP Post Request");
            HttpResponse response = httpclient.execute(httppost);
            
            String str = inputStreamToString(response.getEntity().getContent()).toString();
            Log.w("SENCIDE", str);
            
            if(str.toString().equalsIgnoreCase("true"))
            {
             Log.w("SENCIDE", "TRUE");
             result.setText("Login successful");   
            }else
            {
             Log.w("SENCIDE", "FALSE");
             result.setText(str);             
            }

        } catch (ClientProtocolException e) {
         e.printStackTrace();
        } catch (IOException e) {
         e.printStackTrace();
        }
    } 
  
    private StringBuilder inputStreamToString(InputStream is) {
     String line = "";
     StringBuilder total = new StringBuilder();
     // Wrap a BufferedReader around the InputStream
     BufferedReader rd = new BufferedReader(new InputStreamReader(is));
     // Read response until the end
     try {
      while ((line = rd.readLine()) != null) { 
        total.append(line); 
      }
     } catch (IOException e) {
      e.printStackTrace();
     }
     // Return full string
     return total;
    }

    @Override
    public void onClick(View view) {
      if(view == ok){
        postLoginData();
      }
    }

}
Following code is the content of mail.xml file that is used in the above code.
<?xml version="1.0" encoding="utf-8"?>
<AbsoluteLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<EditText android:layout_width="150px" android:layout_height="wrap_content" android:textSize="18sp" android:id="@+id/txt_username" android:layout_y="132dip" android:layout_x="128dip"></EditText>
<EditText android:layout_width="150px" android:layout_height="wrap_content" android:textSize="18sp" android:password="true" android:id="@+id/txt_password" android:layout_x="128dip" android:layout_y="192dip"></EditText>
<Button android:layout_width="100px" android:layout_height="wrap_content" android:id="@+id/btn_login" android:layout_x="178dip" android:layout_y="252dip" android:text="Login"></Button>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/lbl_username" android:text="User Name" android:layout_x="37dip" android:layout_y="150dip"></TextView>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/lbl_password" android:text="Password" android:layout_y="207dip" android:layout_x="50dip"></TextView>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/lbl_top" android:textSize="16sp" android:typeface="sans" android:text="Please Loggin First" android:layout_x="29dip" android:layout_y="94dip"></TextView>
<TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_y="312dip" android:layout_x="50dip" android:id="@+id/lbl_result"></TextView>
</AbsoluteLayout>
Following code is the content of AndroidManifest.xml file that is used in this project. There note that I have add the line <uses-permission android:name= "android.permission.INTERNET".
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.sencide"
      android:versionCode="1"
      android:versionName="1.0">

 <uses-permission android:name="android.permission.INTERNET" />
    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".AndroidLogin"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>
You can download the source code of above project (Password:sara).

94 comments:

  1. Hey ,
    I didnt understand the following line :

    HttpPost httppost = new HttpPost("http://www.sencide.com/blog/login.php");

    What i have to do if i want to use it on my machine ..with wampserver installed can i simply copy the login.php in www folder and change the url to http://10.0.2.2/login.php , will this work ?

    also i tried entering 'saranga' as username and password but it didnt work...

    can u post login.php file as well

    thanks

    ReplyDelete
  2. @ Karan Balkar,
    That line says where to post data. You should be able to run the code in your machine because my URL is live. There I have used simple php as follows;
    <?php

    $username = $_POST['username'];
    $password = $_POST['password'];

    if($username=='saranga' && $password == 'saranga'){
    echo "true";
    }
    else{
    echo "Login Failed";
    }

    ?>
    You can save this file as login.php and try it as you mentioned.
    Thanks !

    ReplyDelete
  3. Hey I tried the same thing..initially i did not change any thing and tried ur code as it is. The code ran and i got a screen for entering user name and password..i entered 'saranga' for both but it showed login failed.
    Have u made any database ?
    Secondly when i tried my method of putting the login.php file into www folder of wampserver and changing url to http://10.0.2.2/login.php, it didnt work again (activity closed unexpectedly)

    These are the two problems i m facing right now

    Also I wanted to that if i want to insert values from my emulator to my sql local database how can i do that ? Any suggestions ? Do u have any tutorials for the same ?


    THANKS !!! :D

    ReplyDelete
    Replies
    1. can u send me code pls..
      rehan.adpost@gmail.com

      Delete
  4. @ Karan Balkar,

    I tested this code in localhost too, it is working fine. Here I have not use any databases. Did you try using my source code ? It can be downloaded from here.

    To insert values to local database you can use simple socket connection or web services. If time permits I'll post new article on how to access web services in android.
    Thanks !

    ReplyDelete
  5. Hello
    How to login this web
    *****
    URL: http://www.gta.im/login.php Parameter:
    GET
    • u = USERNAME
    • p = PASSWORD (Encrype with MD5)
    Return:
    ok = 0 // Login Error ok = 1 // Login OK uid = xx //USER ID RETURN
    Example:




    URL TESTER: http://www.gta.im/login.php?u=champ&p=e10adc3949ba59abbe56e057f20f883e
    USERNAME: champ PASSWORD: 123456 (MD5: e10adc3949ba59abbe56e057f20f883e)

    ReplyDelete
  6. @ VOLVO2000,
    Did you change the login.php ? It returns error !!
    If you are using GET method you have to use HttpGet class instead of HttpPost.

    ReplyDelete
  7. Thank you very much! It is just what I wanted! But in your example, if the login is correct or not, the programme shows you a message, but I want it to show me another activity depending on the succes or not of the login. I can't get it running. Can you help me? Thank you very much again!

    ReplyDelete
  8. Im getting errors where it says R.id

    ReplyDelete
  9. @ KrLx_roller,
    Yes, this is sample code you can edit for your own purposes. There if the login is correct you can use Forwarding to start another activity.
    Check the following code. It may help you.
    http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/Forwarding.html
    Thank You !

    ReplyDelete
  10. @ androidGod,
    Can I know your eclipse and android version ?
    Thanks !

    ReplyDelete
  11. @ Saranga
    I know how to use it, but the app isn't doing what I want... I don't know why. I'm depressed because I need to introduce this code into the app I'm developing, it's a research work (you will be in the credits haha). I've uploaded the sourcecode to MU. Could you help me? I would appreciate it a lot. Here's the link:

    http://www.megaupload.com/?d=6BF5H2UV

    If my english is unclear, sorry... I'm from Spain, I am still learning english...

    ReplyDelete
  12. @ KrLx_roller,
    I checked your code, you dont need to put OnClickListeners inside postLoginData method.
    Replace line 75 to 103 in your code (AndroidLogin.java) using following code.
    if(str.toString().equalsIgnoreCase("true"))
    {
    Intent intent = new Intent (AndroidLogin.this, Ok.class);
    startActivity(intent);
    finish();
    }
    else
    {
    Intent intent = new Intent (AndroidLogin.this, Error.class);
    startActivity(intent);
    finish();
    }
    Thanks !

    ReplyDelete
  13. @ Saranga
    Could we talk throught email or something like that? I think this will be very long... The app shows me the Error screen always, I mean, putting the user and password correct or not, it shows me that screen. I've tried to change something, to add some stuff... and I get the same final result. But I have to say to you that now, thanks to you, the app shows at least one of two screens, so thank you again.

    I'm expecting really excited for an answer.

    PS: I've changed the old name (KrLx_roller) to my original name (Carlos Frias Ferrer).

    ReplyDelete
  14. @ Carlos Frias Ferrer,
    Please send me your mail id, my gmail id is saranga.rathnayake. I'll send you the corrected application that you have uploded to megaupload.
    Thanks !

    ReplyDelete
  15. Execellent dude .. thanks for the post ..

    Here in the above code u have predefined the username and password .. What if need to register the username and password ??

    Which is nothing but Sing Up ... Looking forward for ur reply ..

    I'm a beginner to android ..

    Pls help me on this ..

    ReplyDelete
  16. @ sai krishna,
    There you can create new form in android and pass newly added data to server as I have done in "postLoginData" method and then you can save them in a database. I have illustrate how to communicate, you can use it for any purposes.

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete
  18. iam created my own database in sqlite for androd.Now pasted that file in assets folder. from assets folder how i can get data. how many files i should use to get that data.

    ReplyDelete
  19. Hi, what the PHP Code for connect with this Httpclient with a MySQL Database?

    I brought it. Can you please post it? Very Thanks!

    ReplyDelete
  20. @roenu,
    try following code,
    <?php
    $host="localhost"; // Host name
    $username="username"; // Mysql username
    $password="pass"; // Mysql password
    $db_name="test"; // Database name
    $tbl_name="members"; // Table name

    // Connect to server and select databse.
    mysql_connect("$host", "$username", "$password")or die("cannot connect");
    mysql_select_db("$db_name")or die("cannot select DB");

    // username and password sent from form
    $myusername=$_POST['username'];
    $mypassword=$_POST['password'];

    // To protect MySQL injection
    $myusername = stripslashes($myusername);
    $mypassword = stripslashes($mypassword);
    $myusername = mysql_real_escape_string($myusername);
    $mypassword = mysql_real_escape_string($mypassword);

    $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'";
    $result=mysql_query($sql);

    // Mysql_num_row is counting table row
    $count=mysql_num_rows($result);

    // If result matched $myusername and $mypassword, table row must be 1 row
    if($count==1){
    echo "true";
    }
    else {
    echo "Login Failed";
    }
    ?>

    ReplyDelete
  21. Hi saranga..
    I'm Rathish, new to Android Developing. I have downloaded your ANDROID LOGIN file and imported in to my Eclipse. Wen i'm trying to run the application it throws error. Please help me out..
    Tanx in Advance

    ReplyDelete
  22. @ Rathu,
    Please tell me what is the error you are getting.

    ReplyDelete
    Replies
    1. Hi...
      I have downloaded your ANDROID LOGIN file and imported in to my Eclipse. Wen i'm trying to run the application it throws error. Please help me out..
      i.e i think some jar files missing so which jar files can i add??

      Delete
  23. Hi Saranga, I love the code and have been using it for a while now without any problems, but now I'm trying to get my app to word on Android 4.0.3 and it crashes when I click the Login button. The LogCat says there's something wrong with the PostLoginData and the onClick action. Please help me.
    Thanks.

    ReplyDelete
  24. @ Jelmer,
    I haven't test this code in version 4, I'll check it and let you know. Did you try web service solution that I have mentioned in Android Web Service Access Tutorial

    ReplyDelete
  25. Hey I have the SQL database for the above, let me know if anyone would like to have that, I saw some people requesting for it.
    Or I can paste here because there is no provision of attachment.


    SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
    SET time_zone = "+00:00";


    CREATE TABLE IF NOT EXISTS `members` (
    `username` varchar(20) collate utf8_unicode_ci NOT NULL,
    `password` varchar(20) collate utf8_unicode_ci NOT NULL
    ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

    --
    -- Dumping data for table `members`
    --

    INSERT INTO `members` (`username`, `password`) VALUES
    ('gaurav', 'gaurav'),
    ('sandip', 'sandip');

    ReplyDelete
  26. Thanks for this posting, it is very helpful. What would I need to change to get https to work? I thought changing the url to https would work bu I get javax.net.ssl.SSLPeerUnverifiedException: No peer certificate

    Any help? Thank you.
    Kam

    ReplyDelete
  27. Hi,
    thank you for your description,
    i have issue here :
    how can we use wcf web services with android use HttpClient?

    Regards,

    ReplyDelete
  28. Hi Saranga,

    how can i use WCF web services in Android?

    Regards

    ReplyDelete
  29. Hi ,
    Im new to android development... I downloaded ur code...
    im using php and Posgresql as my database. But the application is returning login failed, always (but the particular user exist in the database).Any specific settings to be changed ???

    ReplyDelete
  30. Hi,

    When i used my url in this code , it returns login failed always. But the user exist in the database. Im using a php code to connect to the postgresql database.
    Any specific settings to be changed ??

    ReplyDelete
  31. HttpClient httpclient = new DefaultHttpClient();
    HttpPost httppost = new HttpPost("http://some ip address/login1.php");
    try
    Hello,
    Iam trying to create login page in Android using PHP Application server wherein, username and password are being fetched from MySql database through PHP.But iam not able to fetch username and password from Android and iam getting "login failed" on Android Emulator.Please do reply and correct the syntax in the below snippet if any............
    {
    String username1 = username.getText().toString();//edittext
    String password1 = password.getText().toString();//edittext
    List nameValuePairs = new ArrayList(2);
    nameValuePairs.add(new BasicNameValuePair("username", username1));
    nameValuePairs.add(new BasicNameValuePair("password", password1));
    HttpResponse response = httpclient.execute(httppost);
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    HttpEntity entity = response.getEntity();
    txt2.setText(EntityUtils.toString(entity));//textview
    }

    ReplyDelete
  32. Hello,
    Iam trying to create login page in Android using PHP Application server wherein, username and password are being fetched from MySql database through PHP.But iam not able to fetch username and password from Android and iam getting "login failed" on Android Emulator.Please do reply and correct the syntax in the below snippet if any............
    {
    String username1 = username.getText().toString();//edittext
    String password1 = password.getText().toString();//edittext
    List nameValuePairs = new ArrayList(2);
    nameValuePairs.add(new BasicNameValuePair("username", username1));
    nameValuePairs.add(new BasicNameValuePair("password", password1));
    HttpResponse response = httpclient.execute(httppost);
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    HttpEntity entity = response.getEntity();
    txt2.setText(EntityUtils.toString(entity));//textview
    }

    ReplyDelete
  33. Hi Bro. I used your sample from 4shared.com.
    Your App AndroidLogin, I tried on mu emulator.

    I put the username and password = saranga
    and even if I don't put the same, it shows a same error like am complete HTML FILE Source Code, which starting from ::: <!DOCTYPE HTML PUBLIC="// so on...

    What should I do?

    I am attaching link to screen-shots. Please check them out.
    Screen 1:
    https://885427425446120200-a-1802744773732722657-s-sites.googlegroups.com/site/harryb87/Screenshot%20at%202012-01-24%2013%3A50%3A16.png

    Screen 2:
    https://885427425446120200-a-1802744773732722657-s-sites.googlegroups.com/site/harryb87/Screenshot%20at%202012-01-24%2013%3A50%3A43.png

    Screen 3::
    https://885427425446120200-a-1802744773732722657-s-sites.googlegroups.com/site/harryb87/Screenshot%20at%202012-01-24%2013%3A51%3A09.png

    I added scrollview to your design to scroll the error.
    Thanks.
    Haps.

    ReplyDelete
  34. Hi Bro.

    Problem got solved, actually I was running apps in AVD 2.1, it was giving the errors I showed you in above post, but as now I am running AVD 2.3, its running fine in it.

    So it mite be the version problem or something.

    Thanks,
    H@pS.

    ReplyDelete
  35. hi saranga this is praveen. i have one doubt... I have downloaded your ANDROID LOGIN file and imported in to my Eclipse...Wen i'm trying to run the application i entered username and password..Login is successful...upto this i have no doubt...then how can i connect to webservice...what i have do for this webservice

    help me saranga

    Thanks dude

    ReplyDelete
  36. hi saranga this is praveen. i have one doubt... I have downloaded your ANDROID LOGIN file and imported in to my Eclipse...Wen i'm trying to run the application i entered username and password..Login is successful...upto this i have no doubt...then how can i connect to webservice...what i have do for this webservice

    help me saranga

    Thanks dude

    ReplyDelete
  37. hi saranga..,

    how can i connect this application to webservice

    ReplyDelete
  38. Hi Praveen,
    In my post "Android Web Service Access Tutorial" I have modified this application to connect web service and authenticate according to web service response.
    Please follow the code and tell me if you have any problems.
    Thank You !

    ReplyDelete
    Replies
    1. hi i am sohan i am new to android .i have tested your code it is working fine but i want to know how to edit username and password into sohan or some name instead of saranga .could you help me out from this and thanx in advance

      Delete
    2. hi i am sohan i am new to android .i have tested your code it is working fine but i want to know how to edit username and password into sohan or some name instead of saranga .could you help me out from this and thanx in advance

      Delete
  39. hi sir i have been following your tutorials and they are wonderful man.thnks for that.
    however I have successfully succeed to create or to authenticated in "Android Login Screen Using Http Client " as in your android login screen tutorial,then how do I retrieve data of the lodged user in the database via server to my app please help.

    ReplyDelete
  40. Hey Saranga,
    I am tryig to use share point webservices but i am not able to get authentication can you please guide me over it?

    ReplyDelete
  41. Hi ayya,
    I am from UoM.
    When login button pressed, emulator has stopped working. no http response get and not connect with DB. I am using Android 4.0 to create my application. Is it a problem?
    And also how can I use this code to test in my local machine? what is the address should i type?

    ReplyDelete
  42. Hey Saranga,
    If u know how to send current location data to server...plz help me...java2012@gmail.com

    ReplyDelete
  43. hi friends... i have example in php
    i need proper code when user input data from GUI, code in php

    this code is not working
    ";
    print_r($row);
    echo $row['keyword'];
    ?>

    ReplyDelete
  44. Sir, thanks for the tutorial. It really helped me a lot. But when I change the link to localhost, it's not working? Any idea why? I'm using xampp localhost.

    ReplyDelete
  45. Hi, I tried your code but everything application crashes... Any idea?

    ReplyDelete
  46. @hayati fauzy...
    u need to give the IP address of your PC instead of localhost

    ReplyDelete
    Replies
    1. thanks, i manage to connect to localhost. but when it goes to php page, how do i get out from php and jump back to android.

      Delete
  47. I tried your code but everytime the application would close unexpectedly...
    following 2 lines in oncreate() saved my life

    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build();
    StrictMode.setThreadPolicy(policy);

    ReplyDelete
  48. super tutorial how to join to this tutorial

    ReplyDelete
  49. how to get a xml format response in android using webservice?

    ReplyDelete
  50. How to get a xml response in android using webservice?

    ReplyDelete
  51. Is it also serves to web service done in ado.Net or just php?

    ReplyDelete
  52. Is it also serves to web service done in ado.Net or just php?

    ReplyDelete
  53. Great Tutorial,
    How I can fix This Error -> android.os.NetworkOnMainThreadException

    Help Me Plizz

    ReplyDelete
    Replies
    1. OMG, same error for me :((((

      android.os.NetworkOnMainThreadException

      Delete
  54. Nice and great Tutorial,
    but how i can to fix Message error -> Android.Os.NetworkOnMainThreadException ??

    Helpme Pliz...

    ReplyDelete
    Replies
    1. Same error for me :(

      android.os.NetworkOnMainThreadException

      Delete
    2. Same error for me :(

      android.os.NetworkOnMainThreadException

      Delete
  55. hihi I cannot show the login failed ar???

    ReplyDelete
  56. Nice Tutorial.Its very Helpful to me.

    I have Small Question.How to set Android InboxLimit Programatically.
    If limit =10 the incoming New Sms is updated in the First place of the already existing 10 sms's.

    ReplyDelete
  57. Its very nice and helpful to me.

    How to update new incoming sms in first place of the already existing sms.

    ReplyDelete
  58. hii..
    i have download this code and import in eclips but it every time goes in to else portion in the try block and i have also create my login.php page but it deos not show login succusful...can u help me....

    ReplyDelete
  59. I have downloaded your zip file but it is password protected.
    Can you please tell me the password to unzip..

    ReplyDelete
  60. I have 2 questions: Shouldnt be that login in AsyncTask? Because If i try to run this, it shuts the app down. What is doing following code?

    private StringBuilder inputStreamToString(InputStream is) {
    String line = "";
    StringBuilder total = new StringBuilder();
    // Wrap a BufferedReader around the InputStream
    BufferedReader rd = new BufferedReader(new InputStreamReader(is));
    // Read response until the end
    try {
    while ((line = rd.readLine()) != null) {
    total.append(line);
    }
    } catch (IOException e) {
    e.printStackTrace();
    }
    // Return full string
    return total;
    }

    @Override
    public void onClick(View view) {
    if(view == ok){
    postLoginData();
    }
    }


    can you e-mail me on: martin.nemeth@mail.com ? Thank you very much :)

    ReplyDelete
  61. Hi I have 2 questions: Shouldnt this be in AsyncTask? What is doing following code?
    private StringBuilder inputStreamToString(InputStream is) {
    String line = "";
    StringBuilder total = new StringBuilder();
    // Wrap a BufferedReader around the InputStream
    BufferedReader rd = new BufferedReader(new InputStreamReader(is));
    // Read response until the end
    try {
    while ((line = rd.readLine()) != null) {
    total.append(line);
    }
    } catch (IOException e) {
    e.printStackTrace();
    }
    // Return full string
    return total;
    }

    @Override
    public void onClick(View view) {
    if(view == ok){
    postLoginData();
    }
    }

    ReplyDelete
  62. hi sara .why when i login true it not diplay

    ReplyDelete
  63. hi saranga

    is that possible to do the login(local host) in SOAP.

    ReplyDelete
  64. i want android login screen using json obj response format.can any1 help me

    ReplyDelete
  65. i want android login service usiing json response format can any1 help me...asap plz!!

    ReplyDelete
  66. This comment has been removed by the author.

    ReplyDelete
  67. Hello Sir, when am trying to run this project then , it run but when am fill user name "saranga" and password "saranga"/or "saara" and any other then problem is showing...

    android.os.NetworkOnMainThreadException
    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117) and more so please help me.

    ReplyDelete
  68. hi,
    this tutorial is really great.but I'm unable to know how to login..?

    ReplyDelete
  69. This tutorial is really great.But I'm unable to know how to login into it.Is there any necessary thing i have missed during this tutorial

    ReplyDelete
  70. Hi Saranga, This is really good tutorial . I am new to android development. Can u explain the code in here to understand? Because, it will be good to all freshers too. Can u please update with explanation.? I have checked ur application, it worked well. while try to work for my project url , it is not working even username and password are correct? what are the changes I have to make to run in my application?

    ReplyDelete
  71. Hi saranga, This is really great to freshers like me. If u explain the code in details means ,it will be very useful to us. Can u please explain the code in detail.? I have run ur application , it worked well. But while changing url for my project ,it is not getting login even username and password are correct? What r the changes I have to make to run in my application's url.? Thanks in Advance to all. Help me to connect my application with database. Please.

    ReplyDelete
  72. hey buddy i am in a bit of trouble.............

    i ran your code and changed the url to "http://lms.itmindia.edu/lms/login/index.php"
    which is my college website
    but in android nothing happened ... i ran the code in the android phone of mine not the emulator

    ReplyDelete
  73. hey buddy i am in a bit of trouble.............

    i ran your code and changed the url to "http://lms.itmindia.edu/lms/login/index.php"
    which is my college website
    but in android nothing happened ... i ran the code in the android phone of mine not the emulator

    ReplyDelete
  74. Hi friends... I m Sagar Zala. I created login page in android and i want to send data to asmx webservice using json. How can i do this???

    ReplyDelete
  75. Hi friend. I created login page and i want to check login detail through asmx web service. How can i do this?

    ReplyDelete
  76. Hello
    so tanx for this learning
    i used from your codes to make a loging
    i ask my question in Stackoverflow in at this link:
    http://stackoverflow.com/questions/21435753/showing-entered-webpage-site-after-auto-login
    that dont have answer

    Now I need to open the logged in website in my app.

    All is right until I use this code for displaying the logged in webpage:

    WebView wv = new WebView(getApplicationContext());
    wv.loadUrl("http://www.site.com/");
    this.setContentView(wv);

    When I use the above code, this show login webpage to me, not the logged page even though my app logged into the website.

    How can I display the logged site inside my app after my app logs in?

    Tanx again

    ReplyDelete
  77. hi,i have downloaded your login application,but when iam trying to excute the application,the application is not getting launched in android emulator.

    ReplyDelete
  78. i am using webservise of asp.net and when i tryed your code it is not showing anything when is checked the code something is wrong here
    HttpResponse response = httpclient.execute(httppost);
    this line is not executing. what is the problem?

    ReplyDelete
  79. Good tutorial! I hope others tutorials like this existing...

    ReplyDelete
  80. hi,
    there is a problem with the application launching on emulator.
    Please help

    ReplyDelete
  81. Hi,
    Good tutorial, Its very help full my project. Actually my project related on QR code scan and read. I am new in android. Can u please help me?. I made the project, but after I click the login, nothing happening. I don't know where is the error. I don't know how to connect with internet. Please reply me

    Cheers

    ReplyDelete
  82. sir i m going to making android app in helplive i have api in web services already working in web so kindly tell me the sollution to work in the program thank u sir i m krish mishra.nischay3301@gmail.com

    ReplyDelete

Was this information helpful?
Your comments always encourage me to write more, you can post your comment here.

Related Posts :

Related Posts with Thumbnails