Book Image

Testing and securing android studio applications

Book Image

Testing and securing android studio applications

Overview of this book

Table of Contents (18 chapters)
Testing and Securing Android Studio Applications
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Login implementations


We will now see a small example on how to perform authentication using Android. The example we are going to see here uses the login and password combination technique. We are going to start with a very simple example and increase the functionalities as well as the complexities in every iteration.

First of all, we will define EditText and Button, shown as follows:

<EditText
   android:id="@+id/etUsername"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"/>
<EditText
   android:id="@+id/etPassword"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:inputType="textPassword"/> 
<Button
   android:id="@+id/bLogin"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:onClick="login"
   android:text="Login"/>

Now, we are going to check whether the combination of a username and password is good or not. To start, we will simply check whether both the username...