Login Application For Android



Below is a simple android application for login. It accepts user name and password from the user and sends to remote server application for validation/authentication. Finally displays the result to the user.







Step 1: Create the layout for the application.

FirstApp/res/layout/activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="510dip"
    android:layout_marginTop="10dip"
    android:background="#DDDDDD">
    <TextView
        android:id="@+id/tv_un"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="10pt"
        android:textColor="#444444"
        android:layout_alignParentLeft="true"
        android:layout_marginRight="9dip"
        android:layout_marginTop="20dip"
        android:layout_marginLeft="10dip"
        android:text="User Name:"/>
    <EditText
        android:id="@+id/et_un"
        android:layout_width="150dip"
        android:layout_height="wrap_content"
        android:background="@android:drawable/editbox_background"
        android:layout_toRightOf="@id/tv_un"
        android:layout_alignTop="@id/tv_un"
        android:inputType="text"
        />
     <TextView
        android:id="@+id/tv_pw"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="10pt"
        android:textColor="#444444"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/tv_un"
        android:layout_marginRight="9dip"
        android:layout_marginTop="15dip"
        android:layout_marginLeft="10dip"
        android:text="Password:"/>
    <EditText
        android:id="@+id/et_pw"
        android:layout_width="150dip"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dip"
        android:background="@android:drawable/editbox_background"
        android:layout_toRightOf="@id/tv_pw"
        android:layout_alignTop="@id/tv_pw"
        android:layout_below="@id/et_un"
        android:inputType="textPassword"/>"
    <Button
        android:id="@+id/btn_login"
        android:layout_width="100dip"
        android:layout_height="wrap_content"
        android:layout_below="@id/et_pw"
        android:layout_alignParentLeft="true"
        android:layout_marginTop="15dip"
        android:layout_marginLeft="160dip"
        android:text="Login" />
     <TextView
        android:id="@+id/tv_error"
        android:layout_width="400dip"
        android:layout_height="100dip"
        android:textSize="7pt"
        android:layout_alignParentLeft="true"
        android:layout_below="@id/btn_login"
        android:layout_marginRight="9dip"
        android:layout_marginTop="15dip"
        android:layout_marginLeft="120dip"
        android:textColor="#AA0000"
        android:text=""/>
</RelativeLayout>


Step 2: Create a java class to create UI threads.

com.example.firstapp.clientside.LoginLayout.java


/**
 * 
 */
package com.example.firstapp.clientside;

/**
 * @author Prabu
 *
 */
import java.util.ArrayList;

import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;

import com.example.firstapp.R;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

@SuppressLint("NewApi")
public class LoginLayout extends Activity {
 EditText un, pw;
 TextView error;
 Button ok;
 private String resp;
 private String errorMsg;

 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  un = (EditText) findViewById(R.id.et_un);
  pw = (EditText) findViewById(R.id.et_pw);
  ok = (Button) findViewById(R.id.btn_login);
  error = (TextView) findViewById(R.id.tv_error);

  ok.setOnClickListener(new View.OnClickListener() {

   @Override
   public void onClick(View v) {
    /** According with the new StrictGuard policy,  running long tasks on the Main UI thread is not possible
    So creating new thread to create and execute http operations */
    new Thread(new Runnable() {

     @Override
     public void run() {
      ArrayList<NameValuePair> postParameters = new ArrayList<NameValuePair>();
      postParameters.add(new BasicNameValuePair("username",un.getText().toString()));
      postParameters.add(new BasicNameValuePair("password",pw.getText().toString()));

      String response = null;
      try {
       response = SimpleHttpClient.executeHttpPost("http://192.168.1.3:8084/LoginServer/login.do", postParameters);
       String res = response.toString();
       resp = res.replaceAll("\\s+", "");

      } catch (Exception e) {
       e.printStackTrace();
       errorMsg = e.getMessage();
      }
     }

    }).start();
    try {
    /** wait a second to get response from server */
    Thread.sleep(1000);
    /** Inside the new thread we cannot update the main thread
    So updating the main thread outside the new thread */
    
     error.setText(resp);

     if (null != errorMsg && !errorMsg.isEmpty()) {
      error.setText(errorMsg);
     }
    } catch (Exception e) {
     error.setText(e.getMessage());
    }
   }
  });
 }
}



Note: Please use your IP address in below statement;

response = SimpleHttpClient.executeHttpPost("http://192.168.1.3:8084/LoginServer/login.do", postParameters);

http://192.168.1.3:8084/LoginServer/login.do is the url of my server application's servlet.




Step 3: Create a java class to post the username and password to a remote server.

 Normally the database and other resources like servlets will reside in separate computer and the Android application will communicate with that computer to authenticate the user. Thats why we are creating this java class.

com.example.firstapp.clientside.SimpleHttpClient.java


/**
 * 
 */
package com.example.firstapp.clientside;

/**
 * @author Prabu
 *
 */
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URI;
import java.util.ArrayList;

import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.conn.params.ConnManagerParams;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;

public class SimpleHttpClient {
 /** The time it takes for our client to timeout */
    public static final int HTTP_TIMEOUT = 30 * 1000; // milliseconds

    /** Single instance of our HttpClient */
    private static HttpClient mHttpClient;

    /**
     * Get our single instance of our HttpClient object.
     *
     * @return an HttpClient object with connection parameters set
     */
    private static HttpClient getHttpClient() {
        if (mHttpClient == null) {
            mHttpClient = new DefaultHttpClient();
            final HttpParams params = mHttpClient.getParams();
            HttpConnectionParams.setConnectionTimeout(params, HTTP_TIMEOUT);
            HttpConnectionParams.setSoTimeout(params, HTTP_TIMEOUT);
            ConnManagerParams.setTimeout(params, HTTP_TIMEOUT);
        }
        return mHttpClient;
    }

    /**
     * Performs an HTTP Post request to the specified url with the
     * specified parameters.
     *
     * @param url The web address to post the request to
     * @param postParameters The parameters to send via the request
     * @return The result of the request
     * @throws Exception
     */
    public static String executeHttpPost(String url, ArrayList<NameValuePair> postParameters) throws Exception {
        BufferedReader in = null;
        try {
            HttpClient client = getHttpClient();
            HttpPost request = new HttpPost(url);
            UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(postParameters);
            request.setEntity(formEntity);
            HttpResponse response = client.execute(request);
            in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

            StringBuffer sb = new StringBuffer("");
            String line = "";
            String NL = System.getProperty("line.separator");
            while ((line = in.readLine()) != null) {
                sb.append(line + NL);
            }
            in.close();

            String result = sb.toString();
            return result;
        }
        finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    /**
     * Performs an HTTP GET request to the specified url.
     *
     * @param url The web address to post the request to
     * @return The result of the request
     * @throws Exception
     */
    public static String executeHttpGet(String url) throws Exception {
        BufferedReader in = null;
        try {
            HttpClient client = getHttpClient();
            HttpGet request = new HttpGet();
            request.setURI(new URI(url));
            HttpResponse response = client.execute(request);
            in = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));

            StringBuffer sb = new StringBuffer("");
            String line = "";
            String NL = System.getProperty("line.separator");
            while ((line = in.readLine()) != null) {
                sb.append(line + NL);
            }
            in.close();

            String result = sb.toString();
            return result;
        }
        finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}


Step 4: Add permissions to access internet

To be able to access the internet from the application (To send the user name and the password to the remote machine) we need to add permissions using following line to the AndroidManifest.xml file

<uses-permission android:name="android.permission.INTERNET"/>


So your final AndroidManifest.xml file will look like;


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.firstapp"
    android:versionCode="1"
    android:versionName="1.0" >
 
    <uses-sdk android:minSdkVersion="8"
        android:targetSdkVersion="16" />
 <uses-permission android:name="android.permission.INTERNET"/>
    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.firstapp.clientside.LoginLayout"
            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>



Step 5: Create the login server application

We are done at the android application side. Now we need the server application to check the user name and the password. Here I have used a simple web application with a servlet. This application runs in a Tomcat server. You can have your own logic to validate the username and the password in the servlet. You can do database operations etc. But here I am just doing static validation of the username and password.



LoginServlet.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package serverside;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Vienna
 */
public class LoginServlet extends HttpServlet {

    /** 
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
        String un,pw;
        un=request.getParameter("username");
        pw=request.getParameter("password");
        if(un.equalsIgnoreCase("hello") && pw.equals("world"))
            out.print(1);
        else
            out.print(0);
        } finally {            
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /** 
     * Handles the HTTP <code>GET</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Handles the HTTP <code>POST</code> method.
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    /** 
     * Returns a short description of the servlet.
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}



Step 6: We are done and ready to run the application.







Note that this application is just to demonstrate how to make a communication with a remote application. It is always recommended to consider using AsyncTask while making network calls.

This example has been upgraded with SSL support and AsynTaskSupport here. Have a look..


Please dont forget to share your views !!


Source code of the android app: LoginApp.zip

Source code of the server app: LoginServer.zip


 



Reactions:

43 comments :

  1. Code is simple and easy to understand. thanks

    ReplyDelete
  2. When i press the login button i get import android.os.NetworkOnMainThreadException; in username box. how to fix it

    ReplyDelete
    Replies
    1. According with the new StrictGuard policy, running long tasks on the Main UI thread is not possible. So I have created a new thread and given my network logic in the new thread.
      new Thread(new Runnable() {
      //Network/long running task goes here
      }
      Please refer step2. I have clearly mentioned. This will resolve your issue.
      It is recommended to use AsyncTask for such long running/networking tasks to avoid lagging of your application.
      To know how to use AsyncTask please refer AsyncTask tutorial

      Delete
  3. I always get incorrect username or password error.

    ReplyDelete
    Replies
    1. Hi,
      please post the error stack trace so that we can narrow down the issue.

      Delete
    2. i also get the same result

      the error is:

      Unable to start service Intent { act=com.android.email.ACCOUNT_INTENT } U=0: not found
      07-30 00:51:53.271: D/ExchangeService(758): !!! Email application not found; stopping self
      07-30 00:51:53.281: W/ActivityManager(293): Unable to start service Intent { act=com.android.email.ACCOUNT_INTENT } U=0: not found
      07-30 00:51:53.291: D/ExchangeService(758): !!! EAS ExchangeService, onStartCommand, startingUp = true, running = false
      07-30 00:51:53.301: E/ActivityThread(758): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40ce8588 that was originally bound here
      07-30 00:51:53.301: E/ActivityThread(758): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40ce8588 that was originally bound here
      07-30 00:51:53.301: E/ActivityThread(758): at android.app.LoadedApk$ServiceDispatcher.(LoadedApk.java:969)
      07-30 00:51:53.301: E/ActivityThread(758): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
      07-30 00:51:53.301: E/ActivityThread(758): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
      07-30 00:51:53.301: E/ActivityThread(758): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
      07-30 00:51:53.301: E/ActivityThread(758): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
      07-30 00:51:53.301: E/ActivityThread(758): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
      07-30 00:51:53.301: E/ActivityThread(758): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
      07-30 00:51:53.301: E/ActivityThread(758): at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
      07-30 00:51:53.301: E/ActivityThread(758): at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
      07-30 00:51:53.301: E/ActivityThread(758): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
      07-30 00:51:53.301: E/ActivityThread(758): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
      07-30 00:51:53.301: E/ActivityThread(758): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
      07-30 00:51:53.301: E/ActivityThread(758): at android.os.AsyncTask$2.call(AsyncTask.java:287)
      07-30 00:51:53.301: E/ActivityThread(758): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
      07-30 00:51:53.301: E/ActivityThread(758): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
      07-30 00:51:53.301: E/ActivityThread(758): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
      07-30 00:51:53.301: E/ActivityThread(758): at java.lang.Thread.run(Thread.java:856)

      Delete
  4. Hey.. the application looks good but I did not understand the URL used to call the server application. I am trying to execute this with a local host. So I do not know which URL to give. How is it that the login.do file is generated?

    ReplyDelete
    Replies
    1. Hi Navtej singh,
      Looks like you have missed the step5.

      login.do is the separate servlet running in tomcat server. I have created a web project in netbeans with this servlet and that runs in tomcat server.
      The android application communicates with this server app.

      You have to give the url of this server application.

      Delete
    2. use your ip address instead of "localhost"....it might be work

      Delete
  5. Hello, it works ! Good tutorial. but, there is something that i don't understand. I don't understand this:

    Why i have to do click twice in the button login ?

    ReplyDelete
    Replies
    1. I would like to know this as well. Kinda lame.

      Delete
    2. The application sends data to another server that runs somewhere else. It takes time to do the network operation. Maybe you need to wait for few more seconds to see if it actually requires second press (of the login button). During network operation, it may look like the application is not responding. To avoid this we normally use async task to perform the network operations.

      Delete
  6. Hi
    thanks for logic. But I need more about this. Means once I logged in then I need to store the cookies so I can remain login in page transition and in various request.

    ReplyDelete
  7. same as above this code take little bit time when we click on login button

    ReplyDelete
    Replies
    1. The application sends data to another server that runs somewhere else. It takes time to do the network operation. I do not see any other lag in the application.

      Delete
  8. Hello every body,

    I have a problem in step 5,

    Would you explain me how to create the login server application?

    ReplyDelete
    Replies
    1. It is a separate servlet running in tomcat server. I have created a dynamic web project in netbeans with this servlet and that runs in tomcat server.
      The android application communicates with this server app using its url.

      Delete
    2. From netbeans IDE,

      1.Choose File > New Project (Ctrl-Shift-N) from the main menu. Under Categories, select Java Web. Under Projects, select Web Application then click Next. Give a project name and finish the setup.
      2. In projects view, right click on source packages and create new package with any name.(I have named it as serverside).
      3. Right click on the newly created package and create new servlet and name it as LoginServlet
      4. Copy,paste the code we have given in step 5
      5. Save it. Run the project on server.
      Note: you need to have tomcat or glassfish configured on netbeans to run this.


      From the Eclipse IDE, select File > New > Project to view the project wizards. Type Web in the Wizards box, and the New Project window filters the wizards to show the ones that match. This is an easy way to locate the wizard you want instead of going through each item.

      1. Choose Dynamic Web Project from the list and create the project
      2. Expand the project explorer, right click on src and create new package.
      3. Right click on the newly created package and create new Servlet and name it as LoginServlet
      4. Copy,paste the code we have given in step 5
      5. Right click on project>Run as>Run on server>select any of the server you have>finish

      Delete
  9. faceing error at is empty......!! plz help

    if (null != errorMsg && !errorMsg.isEmpty()) {

    ReplyDelete
    Replies
    1. What is the error you are facing?
      Give us more information about the error!

      Delete
  10. This method isEmpty() is undefined for the type string.
    This is the error and one more thing i can not understand your 5 step can you explain me pleasure!!! how you can do it. Actually i am totally new in android world.............

    ReplyDelete
    Replies
    1. isEmpty() method is available since java 1.6. From your error message, we think that your workspace is using java version <1.6.
      Please go to Eclipse preference->java->compiler and change the compiler version to 1.6


      About the step:5
      It is a separate servlet running in tomcat server. I have created a dynamic web project in netbeans with this servlet and that runs in tomcat server.
      The android application communicates with this server app using its url.

      Please read previous comments, we have already explained this!!!

      Delete
    2. it's compiler version is already 1.6........................:-(

      Delete
  11. Can you give me the code for registration ?
    With username,password and phonenumber

    ReplyDelete
  12. This is a nice tutorial but i have to tap the login button twice. I have waited a long time after a single tap and nothing happens , but if i tap twice then the result is printed instantly can you please help me ?

    ReplyDelete
    Replies
    1. The main thread doesn't wait for the response from server. It immediately renders the view. We recommend to use asyncTask while doing a network operation.

      Delete
  13. I tried to use your tutorial to fix my app's registrationActivity.java which was running on the Main thread, It resulted in My app finally registering by sending the data to my online database but it crashes straight away giving me this error:


    01-18 15:48:04.361: E/AndroidRuntime(2052): FATAL EXCEPTION: Thread-116
    01-18 15:48:04.361: E/AndroidRuntime(2052): Process: com.milamboltd.barz, PID: 2052
    01-18 15:48:04.361: E/AndroidRuntime(2052): android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
    01-18 15:48:04.361: E/AndroidRuntime(2052): at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:6006)
    01-18 15:48:04.361: E/AndroidRuntime(2052): at android.view.ViewRootImpl.invalidateChildInParent(ViewRootImpl.java:855)
    01-18 15:48:04.361: E/AndroidRuntime(2052): at android.view.ViewGroup.invalidateChild(ViewGroup.java:4320)
    01-18 15:48:04.361: E/AndroidRuntime(2052): at android.view.View.invalidate(View.java:10919)
    01-18 15:48:04.361: E/AndroidRuntime(2052): at android.view.View.invalidate(View.java:10874)
    01-18 15:48:04.361: E/AndroidRuntime(2052): at android.widget.TextView.checkForRelayout(TextView.java:6598)
    01-18 15:48:04.361: E/AndroidRuntime(2052): at android.widget.TextView.setText(TextView.java:3824)
    01-18 15:48:04.361: E/AndroidRuntime(2052): at android.widget.TextView.setText(TextView.java:3682)
    01-18 15:48:04.361: E/AndroidRuntime(2052): at android.widget.TextView.setText(TextView.java:3657)
    01-18 15:48:04.361: E/AndroidRuntime(2052): at com.milamboltd.barz.LoginActivity$1$1.run(LoginActivity.java:68)
    01-18 15:48:04.361: E/AndroidRuntime(2052): at java.lang.Thread.run(Thread.java:841)
    If you could help me fix my code below I know I am almost there ??

    ReplyDelete
    Replies
    1. It seems you are trying to update your View (Layout) from some other thread. Try to 'return' the value to your Main Activity class and update the view from there.

      If this doesn't help, please post your code block here so that we can understand better.

      Delete
  14. hey is it possible to just get a full source code in zip package of this ????? Thanks R.!

    ReplyDelete
    Replies
    1. Please find the source code zip above.

      Delete
  15. i am getting error as: connection to localhost:8084 refused..please help

    ReplyDelete
  16. whats the different between webservice and httpclient

    ReplyDelete
  17. You said that http://192.168.1.3:8084/LoginServer/login.do is the url of your server application's servlet.
    I've created the servlet in NetBeans but what do I have to write as URL in response = SimpleHttpClient.executeHttpPost("???") ? I've made a copy from serrvlet project an put it in tomcar->webapp->ROOT and I tried the following URL response = SimpleHttpClient.executeHttpPost(
    "http://10.0.2.2:8080/LoginServer/LoginServlet",
    postParameters); but it doesn't work

    ReplyDelete
    Replies
    1. 1. check your ip address
      2. LoginServer should the your application name
      3. LoginServlet should be the name of servlet mapping in web.xml

      Delete
  18. This is working perfectly in the emulator, but says connection refused on the actual device. what could be the problem?

    ReplyDelete
    Replies
    1. In first case, both server and client are in same machine. So no problem. But in second case they are in different devices.To access the sever app from android mobile, your server app should be hosted on internet. One simple way is creating a web service and hosting it on internet.

      see this post to know to create a simple web service

      http://www.compiletimeerror.com/2013/09/creating-java-web-service-using-axis-2.html

      see this post to know how to access the web service from android application

      http://www.compiletimeerror.com/2013/09/accessing-web-service-from-android.html

      Delete
  19. This comment has been removed by the author.

    ReplyDelete
  20. Hello, good tutorial, however, a export de apk file and install it in android devices with android 4.0 and i only get "Se ha detenido la ejecuciĆ³n de la app": the app has been sttoped.

    I have tried in 3 different devices.

    ReplyDelete
  21. I am not getting any response from server. Even System.out.println is blank in logcat. Could you please explain me why??

    ReplyDelete
  22. [2014-05-26 00:37:46 - FirstApp] Starting activity com.example.firstapp.clientside.LoginLayout on device emulator-5554
    [2014-05-26 00:37:49 - FirstApp] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.firstapp/.clientside.LoginLayout }
    [2014-05-26 00:37:49 - FirstApp] New package not yet registered with the system. Waiting 3 seconds before next attempt.
    [2014-05-26 00:37:52 - FirstApp] Starting activity com.example.firstapp.clientside.LoginLayout on device emulator-5554
    [2014-05-26 00:37:54 - FirstApp] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.example.firstapp/.clientside.LoginLayout }
    [2014-05-26 00:37:54 - FirstApp] ActivityManager: Error type 3
    [2014-05-26 00:37:54 - FirstApp] ActivityManager: Error: Activity class {com.example.firstapp/com.example.firstapp.clientside.LoginLayout} does not exist.


    I am getting above error.Please help.

    ReplyDelete
  23. hi
    i want to connect to an access point router that is connect to an imbedded web server with IP address: http://192.168.1.100. when i click on login button i face to this error:
    HTTP 1.0 401 Error. Unauthorized Access
    You are not authorized to access this server. please help me

    ReplyDelete

Ads