Android Question Java InterfaceObject

Jithesh Mepparambath

Member
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.app.Activity;
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) {

super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
tli = new TallyLoginInterface();
// Set true to Login to TallyNET Online
// Set false to Login to Cached data Locally
tli.SetLoginModeOnline(true);
Intent i = new Intent(this, tli.getClass());
startActivityForResult(i, 1);
}
catch (Exception e) {
e.toString();
}
}
@override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
// TODO Auto-generated method stub
super.onActivityResult(requestCode, resultCode, data);
if(resultCode==1){
// 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
}
else
{
// resultCode other than 1 implies failure
Toast.makeText(this, tli.GetErrorDescription(), Toast.LENGTH_LONG).show();
}
}
}

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

waiting for a positive result
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can create a tli object with:
B4X:
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: http://www.b4x.com/android/forum/threads/40374/#content[/code]
 
Upvote 0
Top