Android Question Java InterfaceObject

Jithesh Mepparambath

Licensed User
Longtime User
Hi ,
How can I use a Java Class Interface Object.

I am having a Java Class interface file provided by a Software vendor which validates a User credentials in their software and returns a SESSION ID , LoginKEY . They have provided a sample code which can be run from Java and for Android platform. please find below the code

//************* Start of Code
package com.example.useloginlib;

import com.tally.login.*;

import android.content.Intent;
import android.os.Bundle;
import android.widget.Toast;

public class UseLoginLib extends Activity {
/** Called when the activity is first created.
*/ String SessionID = null;
String UserName = null;
String Password = null;
TallyLoginInterface tli = null;
@override public void onCreate(Bundle savedInstanceState) {

try {
tli = new TallyLoginInterface();
// Set true to Login to TallyNET Online
// Set false to Login to Cached data Locally
Intent i = new Intent(this, tli.getClass());
startActivityForResult(i, 1);
catch (Exception e) {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
// resultCode 1 implies the Login was successful
SessionID = tli.GetSessionID();
UserName = tli.GetTallyNETID();
Password = tli.GetLoginKey();
Toast.makeText(this, SessionID, Toast.LENGTH_LONG).show();
Toast.makeText(this, UserName, Toast.LENGTH_LONG).show();
Toast.makeText(this, Password, Toast.LENGTH_LONG).show();
Toast.makeText(this, SessionID, Toast.LENGTH_LONG).show();
// on success your Code goes here
// resultCode other than 1 implies failure
Toast.makeText(this, tli.GetErrorDescription(), Toast.LENGTH_LONG).show();

//************* End of Code

waiting for a positive result


B4X founder
Staff member
Licensed User
Longtime User
You can create a tli object with:
Dim tli As JavaObject
tli.InitializeNewInstance("com.tally.login.TallyLoginInterface", null)
You need to also add the activity to the manifest file with AddApplicationText.

Then you will be able to create the intent and call it with:[/code]
Upvote 0