Archive for the Android Programming Category

Biometrics on Mobility

Posted in Android Programming on July 2, 2012 by Abir Atarthy

                      By    Tanaya  Karmakar

Hi friends , today I am going to discuss about biometrics authentication and its scope in mobile environment and several use cases . Before that , you have to know what is biometrics ????? Biometrics is basically a science for analyzing and measuring biological data but here we are concerned about biometrics in IT world which basically means authenticating a person by analyzing the biological traits (like fingerprints , iris , face , voice etc).

Authentication by Biometric Identification increasing day by day in the corporate , public security systems , consumer electronics and point of sale applications . Authenticating a person from his/her biological traits is much more secure than traditional authentication system (authentication by password )  because it can easily prevent brute-force and dictionary attacks which are the most common methods against compromising user accounts .

Now I will discuss how a biometrics enabled authentication system works …..

Each authentication system consists of the following steps ….

  •       Registration Phase
  •       Login Phase
  •       Transmission Phase
  •       Verification Phase
  •       Data Transfer Phase

Now I am going to discuss how these steps can be applied in case Biometrics enabled authentication from mobile device .

Registration Phase :-

This is first phase of authentication system (be it biometrics enabled or traditional password based ) . In case of traditional authentication system users are requested to enter their name , email id and some other relevant details , sometimes users are requested to choose their own password and sometimes the service system for which they are registering generates password for that user and sends it to the email id provided by the user .

In case of biometrics enabled authentication system , biometrics data is captured (like fingerprints , voice , face or iris ) . Then features are extracted ( points of interest ) and the extracted features are stored as template against that particular user . This template is used during the verification phase to determine the legitimate user . The system may provide an eID(basically user ID ) and a password which will be used at early point of login phase .

Login Phase/Handshake Phase , Transmission Phase ,Verification Phase :-

Login phase second phase , where the user is asked to login in order to access their data .  As I mentioned that in addition to capturing biometric data the system may provide an eID (user ID) and password to the user . If this thing happens then the authentication system may ask the user to enter the eID and the password and the biometrics data .  Now , the user data has to be transmitted through the internet which happens in the transmission phase . Obviously , the internet is an insecure channel so there is a high chance that the login credentials can be accessed by the hackers , in that case steganography can used where the login credentials are hidden inside any audio or video .

After that the verification phase comes , where the credentials entered by the user is checked against the stored one (obviously after extracting the login data from the audio or video ) . If match is found then the user enters the data transfer phase otherwise error message is sent to the user .

Data Transfer Phase :  – This is the last and final phase where user can access their data after successful login .

So , this was all about a proposed authentication steps for a biometrics enabled authentication system . Now I will be discussing about biometrics in mobile phones .

MOBIO(MObile BIOmetry)  :-

“MOBIO concept is to develop new mobile services secured by biometric authentication means. Scientific and technical objectives include robust-to-illumination face authentication, robust-to-noise speaker authentication, joint bi-modal authentication, model adaptation and scalability.” – claimed by official website of MOBIO (http://www.mobioproject.org/).

It cannot be denied that now a days Mobile  phone is not only a phone , other than talking , a lot more things can be done using mobile like internet surfing , payment using mobile phone , determining users current location , games  etc . Not only that , using augmented reality concept , mobile phone can also guide a user to particular route while driving , it can also show floor plan of a particular building .  Time will come when mobile will be used as pluggable CPU for the computers .  Anyway , my goal is not to discuss what is being done and what can be done with a mobile device , what I am going to discuss is to let you know what MOBIO is planning for Biometric authentication.

In case of mobile payment , user needs to authenticate first which is a traditional mechanism like entering password or PIN numbers which can easily be shared , stolen , observed , compromised .  So , MOBIO will focus on providing biometrics authentication for mobile payment and related situations . Now a days , more and more portable devices are quipped with video camera and microphone, hence MOBIO  will focus on multiple aspects of biometrics authentication based on face and voice authentication .

BMBA(Bi-Modal Biometric Authentication) :-

As claimed by MOBIO team , they will carry research on joint bi-modal biometry under various realistic conditions .

They will investigate the following technologies :

  •      Face localization and speech segmentation in noisy environments .
  •      Video based face authentication .
  •      Speaker authentication .
  •      Bi-modal authentication.

In order to get detailed information about MOBIO , please go to their official website (mentioned above).

How to built Android Apps: Tic Tac Toe

Posted in Android Programming on March 8, 2012 by Abir Atarthy

Make your own Android Apps: Tic Tac Toe 

                                                — Tanaya Karmaker

Hello friends , after a long time , I am posting here . In this post , I have designed the tic tac toe game for your android phone (though the .apk file is not here , I am providing the source code ).This article is not for them those who have zero idea about how to design android apps . Here , I am assuming that you at least know how to run Hello World program in android . So , enjoy ….

  1. Edit the main.xml , so that it looks like as follows :-

<?xml version=“1.0” encoding=“utf-8”?>

<RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android&#8221;

    android:layout_width=“fill_parent”

    android:layout_height=“fill_parent”

    android:orientation=“vertical” >

    <TextView

        android:id=“@+id/header”

        android:layout_width=“fill_parent”

        android:layout_height=“wrap_content”

        android:text=“@string/hello”

        android:layout_marginLeft=“120dip”

        android:layout_marginTop=“20dip”

        android:layout_marginRight=“120dip”

        android:typeface=“sans”

        android:textColor=“#ffaa00”></TextView>

    <Button

        android:id=“@+id/btn00”

        android:layout_height=“50px”

        android:layout_width=“50px”

        android:layout_marginLeft=“70dip”

        android:layout_marginRight=“10dip”

        android:layout_below=“@+id/header”

        android:layout_marginBottom=“10dip”

        android:layout_marginTop=“20dip”

        android:text=“”></Button>

    <Button

        android:id=“@+id/btn01”

        android:layout_height=“50px”

        android:layout_width=“50px”

        android:layout_marginLeft=“10dip”

        android:layout_marginRight=“10dip”

        android:layout_marginTop=“20dip”

        android:layout_marginBottom=“10dip”

        android:layout_below=“@+id/header”

        android:layout_toRightOf=“@+id/btn00”

        android:text=“”></Button>

    <Button

        android:id=“@+id/btn02”

        android:layout_height=“50px”

        android:layout_width=“50px”

        android:layout_marginLeft=“10dip”

        android:layout_marginTop=“20dip”

        android:layout_marginBottom=“10dip”

        android:layout_below=“@+id/header”

        android:layout_toRightOf=“@+id/btn01”

        android:text=“”></Button>/

     <Button

         android:id=“@+id/btn10”

         android:layout_width=“50px”

         android:layout_height=“50px”

         android:layout_marginLeft=“70dip”

         android:layout_marginRight=“10dip”

         android:layout_marginTop=“10dip”

         android:layout_marginBottom=“10dip”

         android:layout_below=“@+id/btn00”

         android:text=“”></Button>”

      <Button

          android:id=“@+id/btn11”

          android:layout_width=“50px”

          android:layout_height=“50px”

          android:layout_marginLeft=“10dip”

          android:layout_marginRight=“10dip”

          android:layout_marginTop=“10dip”

          android:layout_marginBottom=“10dip”

          android:layout_below=“@+id/btn01”

          android:layout_toRightOf=“@+id/btn10”

          android:text=“”></Button>

      <Button

          android:id=“@+id/btn12”

          android:layout_width=“50px”

          android:layout_height=“50px”

          android:layout_marginLeft=“10dip”

          android:layout_marginTop=“10dip”

          android:layout_marginBottom=“10dip”

          android:layout_below=“@+id/btn02”

          android:layout_toRightOf=“@+id/btn11”

          android:text=“”></Button>

      <Button

          android:id=“@+id/btn20”

          android:layout_width=“50px”

          android:layout_height=“50px”

          android:layout_marginLeft=“70dip”

          android:layout_marginRight=“10dip”

          android:layout_marginTop=“10dip”

          android:layout_marginBottom=“10dip”

          android:layout_below=“@+id/btn10”

          android:text=“”></Button>

      <Button

          android:id=“@+id/btn21”

          android:layout_width=“50px”

          android:layout_height=“50px”

          android:layout_marginLeft=“10dip”

          android:layout_marginRight=“10dip”

          android:layout_marginTop=“10dip”

          android:layout_marginBottom=“10dip”

          android:layout_below=“@+id/btn11”

          android:layout_toRightOf=“@+id/btn20”

          android:text=“”></Button>

      <Button

          android:id=“@+id/btn22”

          android:layout_width=“50px”

          android:layout_height=“50px”

          android:layout_marginLeft=“10dip”

          android:layout_marginTop=“10dip”

          android:layout_marginBottom=“10dip”

          android:layout_below=“@+id/btn12”

          android:layout_toRightOf=“@+id/btn21”

          android:text=“”></Button>

      <TextView

          android:id=“@+id/txtLbl”

          android:layout_width=“wrap_content”

          android:layout_height=“wrap_content”

          android:layout_marginLeft=“70dip”

          android:layout_marginRight=“10dip”

          android:layout_marginTop=“20dip”

          android:layout_marginBottom=“10dip”

          android:layout_below=“@+id/btn20”

          android:text=“Playing : “></TextView>

      <TextView

          android:id=“@+id/playerLbl”

          android:layout_width=“wrap_content”

          android:layout_height=“wrap_content”

          android:layout_marginLeft=“10dip”

          android:layout_marginRight=“10dip”

          android:layout_marginTop=“20dip”

          android:layout_marginBottom=“10dip”

          android:layout_below=“@+id/btn21”

          android:layout_toRightOf=“@+id/txtLbl”

          android:text=“Player1”></TextView>

     </RelativeLayout>

  1. This is the source code (file name:-TicTacToeFinalActivity.java)

package com.game;

import android.app.Activity;

import android.app.AlertDialog;

import android.app.Dialog;

import android.content.DialogInterface;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.TextView;

public class TicTacToeFinalActivity extends Activity {

    /** Called when the activity is first created. */

          Button btn00,btn01,btn02,btn10,btn11,btn12,btn20,btn21,btn22;

          AlertDialog.Builder alert,error;

          TextView playerLbl,header;

    @Override

    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.main);

        setClickEvent();

          }

    public void setClickEvent()

    {

          btn00=(Button)findViewById(R.id.btn00);

          btn01=(Button)findViewById(R.id.btn01);

          btn02=(Button)findViewById(R.id.btn02);

          btn10=(Button)findViewById(R.id.btn10);

          btn11=(Button)findViewById(R.id.btn11);

       btn12=(Button)findViewById(R.id.btn12);

          btn20=(Button)findViewById(R.id.btn20);

          btn21=(Button)findViewById(R.id.btn21);

          btn22=(Button)findViewById(R.id.btn22);

          btn00.setOnClickListener(new Clicker());

          btn01.setOnClickListener(new Clicker());

          btn02.setOnClickListener(new Clicker());

          btn10.setOnClickListener(new Clicker());

          btn11.setOnClickListener(new Clicker());

          btn12.setOnClickListener(new Clicker());

          btn20.setOnClickListener(new Clicker());       

          btn21.setOnClickListener(new Clicker());

          btn22.setOnClickListener(new Clicker());

       }

    public void resetButton()

      {

                 btn00.setText(“”);

                 btn01.setText(“”);

                 btn02.setText(“”);

                 btn10.setText(“”);

                 btn11.setText(“”);

                 btn12.setText(“”);

                 btn20.setText(“”);

                 btn21.setText(“”);

                 btn22.setText(“”);

                 playerLbl.setText(“Player1”);

                 header=(TextView)findViewById(R.id.header);

                 header.setText(“Tic Tac Toe : New Game”);

    }

    public void createDialog()

    {

          alert=new AlertDialog.Builder(this);

          alert.setTitle(“Winner”);

          alert.setPositiveButton(“OK”,new DialogInterface.OnClickListener() {

                 public void onClick(DialogInterface dialog, int which) {

                        // TODO Auto-generated method stub

                               resetButton();

                        }

                 });

          error=new AlertDialog.Builder(this);

          error.setTitle(“Error”);

          error.setMessage(“This cell is occupied”);

          error.setPositiveButton(“OK”,new DialogInterface.OnClickListener() {

                 public void onClick(DialogInterface dialog, int which) {                             // TODO Auto-generated method stub

                        }

                 });

    }

    public boolean determineWinner()

    {

          createDialog();

          if(btn00.getText().toString().equals(“X”)&&

btn01.getText().toString().equals(“X”) && btn02.getText().toString().equals(“X”))

          {

                 alert.setMessage(“Winner is : Player1”);

                 alert.show();

                 return true;

          }

if(btn00.getText().toString().equals(“X”) && btn10.getText().toString().equals(“X”) && btn20.getText().toString().equals(“X”))

          {

                 alert.setMessage(“Winner is : Player1”);

                 alert.show();

                 return true;

          }

if(btn10.getText().toString().equals(“X”) && btn11.getText().toString().equals(“X”) && btn12.getText().toString().equals(“X”))

          {

                 alert.setMessage(“Winner is : Player1”);

                 alert.show();

                 return true;

          }

if(btn20.getText().toString().equals(“X”) && btn21.getText().toString().equals(“X”) && btn22.getText().toString().equals(“X”))

          {

                 alert.setMessage(“Winner is : Player1”);

                 alert.show();

                 return true;

          }

if(btn01.getText().toString().equals(“X”) && btn11.getText().toString().equals(“X”) && btn21.getText().toString().equals(“X”))

          {

                 alert.setMessage(“Winner is : Player1”);

                 alert.show();

                 return true;

          }

if(btn02.getText().toString().equals(“X”) && btn12.getText().toString().equals(“X”) && btn22.getText().toString().equals(“X”))

          {

                 alert.setMessage(“Winner is : Player1”);

                 alert.show();

                 return true;

          }

if(btn00.getText().toString().equals(“X”) && btn11.getText().toString().equals(“X”) && btn22.getText().toString().equals(“X”))

          {

                 alert.setMessage(“Winner is : Player1”);

                 alert.show();

                 return true;

          }

if(btn02.getText().toString().equals(“X”) && btn11.getText().toString().equals(“X”) && btn20.getText().toString().equals(“X”))

          {

                 alert.setMessage(“Winner is : Player1”);

                 alert.show();

                 return true;

          }

if(btn00.getText().toString().equals(“0”) && btn01.getText().toString().equals(“0”) && btn02.getText().toString().equals(“0”))

          {

                 alert.setMessage(“Winner is : Player2”);

                 alert.show();

                 return true;

          }

if(btn10.getText().toString().equals(“0”) && btn11.getText().toString().equals(“0”) && btn12.getText().toString().equals(“0”))

          {

                 alert.setMessage(“Winner is : Player2”);

                 alert.show();

                 return true;

          }

if(btn20.getText().toString().equals(“0”) && btn21.getText().toString().equals(“0”) && btn22.getText().toString().equals(“0”))

          {

                 alert.setMessage(“Winner is : Player2”);

                 alert.show();

              return true;

       }

if(btn00.getText().toString().equals(“0”) && btn10.getText().toString().equals(“0”) && btn20.getText().toString().equals(“0”))

       {

              alert.setMessage(“Winner is : Player2”);

              alert.show();

              return true;

       }

if(btn01.getText().toString().equals(“0”) && btn11.getText().toString().equals(“0”) && btn21.getText().toString().equals(“0”))

       {

              alert.setMessage(“Winner is : Player2”);

              alert.show();

              return true;

       }

if(btn02.getText().toString().equals(“0”) && btn12.getText().toString().equals(“0”) && btn22.getText().toString().equals(“0”))

       {

              alert.setMessage(“Winner is : Player2”);

              alert.show();

              return true;

       }

if(btn00.getText().toString().equals(“0”) && btn11.getText().toString().equals(“0”) && btn22.getText().toString().equals(“0”))

       {

              alert.setMessage(“Winner is : Player2”);

              alert.show();

              return true;

       }

if(btn02.getText().toString().equals(“0”) && btn11.getText().toString().equals(“0”) && btn20.getText().toString().equals(“0”))

       {

              alert.setMessage(“Winner is : Player2”);

              alert.show();

              return true;

       }

       return false;

    }

    public void checkAgain()

    {

       boolean flag;

       if(!btn00.getText().toString().equals(“”) && !btn01.getText().toString().equals(“”) && !btn02.getText().toString().equals(“”) && !btn10.getText().toString().equals(“”) && !btn11.getText().toString().equals(“”) && !btn12.getText().toString().equals(“”) && !btn20.getText().toString().equals(“”) && !btn21.getText().toString().equals(“”) && !btn22.getText().toString().equals(“”))

       {

              flag=determineWinner();

              if(!flag)

              {

                     alert.setMessage(“No One Won , GAME OVER !!!!! “);

                     alert.show();

              }            

       }

    }

    class Clicker implements OnClickListener

    {

       boolean flag;

       public void onClick(View v)

       {

              playerLbl=(TextView)findViewById(R.id.playerLbl);

              String lbl=playerLbl.getText().toString();

              Button btn=(Button)v;

              if(btn.getText().toString().equals(“”))

              {

                     if(lbl.equals(“Player1”))

                     {

                           btn.setText(“X”);

                           playerLbl.setText(“Player2”);

                     }

                     else

                     {

                           btn.setText(“0”);

                           playerLbl.setText(“Player1”);

                     }

              }

              else

              {

                     error.show();

              }

              flag=determineWinner();

              if(!flag)

              {

                     checkAgain();

              }            

       }

    }

}

Output :-