https://help.tallysolutions.com/docs/td9rel54/auth_lib/android_platform.htm

Android Platform

This topic explains the prerequisites, the process of including and using Tally Authentication Library in the Android application project, and the available API/methods.

Prerequisites

1. Add the permissions in the AndroidManifest.xml of the application, in which the authentication library is to be used.

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

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

2. Add the login activity details in the AndroidManifest.xml to register it with Android.

< activity a ndroid:name = "com.tallysolutions.tallyauthenticationlibrary.TallyLoginActivity"

android:configChanges = "orientation|screenSize" >

</ activity >

Including the Library in Android Project

To include Tally Authentication Library in the Android application project

1. R ight-click the project in which the authentication library is to be used.

2. Click Build Path .

3. Select Configure Build Path .

4. Select Libraries tab.

5. Click Add external JARs .

6. Go to the folder where the Tally Authentication Library is located, select the . jar file, and click Open.

7. Select Order and Export tab.

8. Select .jar file for the Tally Authentication Library, if not already selected, and click OK .

Using the Library in Android Project

1. Set the developer mode to true, when application is in testing phase

TallyLoginInterface.setDeveloperMode(true);

OR

TallyLoginInterface. setDeveloperMode ( false );

2. Set the online mode before displaying the login screen. The library operates in offline (disconnected) mode by default.

TallyLoginInterface. setOnlineMode ( true );

3. Display the login screen activity using the correct Intent .

Intent loginIntent = new Intent( this , TallyLoginActivity. class );

startActivityForResult(loginIntent, 1);

4. Override the method onActivityResult to receive the authentication completed event.

5. This method gets called when authentication is done successfully or when the LoginActivity is closed by the user.

@Override

protected void onActivityResult( int requestCode, int resultCode, Intent data)

{

super .onActivityResult(requestCode, resultCode, data);

if (requestCode == 1)

{

//call the methods provided by TallyLoginInterface for retrieving authentication information

if (resultCode == RESULT_OK )

{

String username = TallyLoginInterface. getTallyNetID ();

boolean mode = TallyLoginInterface. getOnlineMode ();

int errorCode = TallyLoginInterface. getErrorCode ();

String errorMsg = TallyLoginInterface. getErrorDescription ();

String libver = TallyLoginInterface. getLibraryVersion ();

String sessionId= TallyLoginInterface. getSessionID ();

}

}

}

API/Methods Provided

Two public classes are provided from the library to the third party developers, namely

1. TallyLoginActivity : Displays the login screen to the user.

2. TallyLoginInterface : Retrieves information after the authentication is completed (either successfully or unsuccessfully). It also sets the mode to operate the library.

API/Methods of TallyLoginInterface class are listed below:

API/Methods

Purpose

void setOnlineMode(boolean)

To set the mode (online/offline) in which the library operates. If not set, by default the library operates in offline environment.

boolean getOnlineMode()

To get the current mode (online/offline) in which the library is operating.

String getTallyNetID()

To get the Tally.NET ID where library has authenticated, either successfully or unsuccessfully.

String getSessionID()

To get the Session ID after the successful authentication, or it returns null.

Int getErrorCode()

To get the error code after an unsuccessful authentication. If the authentication is successful, this method returns null.

String getErrorDescription()

To get the error description corresponding to the error code, after an unsuccessful authentication.

If the authentication is successful, this method returns null.

String getLibraryVersion()

To get the current version of the library.

String getStatus()

To get the status of the authentication done by the library.

0 – Success

1 – Failure

void setDeveloperMode(boolean)

To set the developer mode for the library.

In developer mode, library points to the test server.

boolean isDeveloperMode()

To check whether the library is currently working in developer mode or not.