Java Question Wrapping Genius Scan SDK

Michael2150

Member
Licensed User
Hi so this is my first attempt at making a library for B4a, and a big attempt it is. I have a project that requires the Genius Scan SDK. So after a few days of research I've gone through most of the tutorials on the forum about how to make your own B4a library, and they are all great, but I still can't seem to know where to start when trying to get this going. A little help or push into the right direction from someone a bit more experienced would be helpful.

I have the Eclipse project set up with the B4aShared, Core, android jar files, but that's kinda where I get stuck.
I have a sample project open in Android Studio that shows the SDK at work, it can be found here.
I also have the getting started documentation here.

Thanks.
 

Biswajit

Active Member
Licensed User
Longtime User
As per the API documentation, it seems the SDK is a bit complex has lots of classes, interfaces, and methods. If you are good at java and familiar with the eclipse IDE then it will be easy to get started. If not then I would recommend asking someone experienced to wrap it and then study the source code for better understanding. Here is the simple procedure I follow for wrapping an SDK,
  1. Create a java project in eclipse
  2. Import latest android.jar, core.jar, b4ashared.jar and the jar file(s) of the SDK.
  3. Create a package (eg. com.thesdkname.wrapper)
  4. Create a class with the name of the SDK which will have the information required for the B4A like dependencies, events, shortname etc. This will be the main entry point.
  5. Define a private variable that will hold the object and that you will use to call the internal methods after initializing (Eg. private YourSDKClass myVar; )
  6. Define two private variables, _eventname and _ba; (eventname is required when you want to send some data from the wrapper to the B4A via an event, and the ba variable is required to raise the event)
  7. Create a method called initialize with a minimum two parameters first one of BA type and the second one is of string type (eg. public void initialize(BA ba, String eventname) )
  8. Here I saw the SDK needs a KEY for initialization so you can also pass a third parameter that will hold the KEY required for initialization.
  9. Then store the ba and eventname parameter value to those private variables (_ba, _eventname)
  10. Then initialize the main class (check the api documentation) and store the result to the first private variable you defined in step 5.
  11. Then check the api documentation for the methods available for that particular class and write a method with the same name for better understanding.
  12. Java:
    public void theMethodName(){ //this is the method name you will be calling from B4A
    myVar.theMethodName(); //this is the internal method
    }
    //or a return type method
    public int theMethodName2(){ //this is the method name you will be calling from B4A
    return myVar.theMethodName2(); //this is the internal method
    }
    //or a method with parameters
    public void theMethodName3(String param1){ //this is the method name you will be calling from B4A
    myVar.theMethodName3(param1); //this is the internal method
    }
  13. Now to wrap another sdk class just create another class inside the package and repeat the same procedure from step 5.
  14. After you are done download the simple library compiler and browse the eclipse project folder. In case of any error, it will notify you else it will generate a jar and a XML file inside the additional library folder.
  15. Now copy the jar files from the SDK to the additional library folder and your wrapper is ready to be used in B4A.

Note: This is a very basic guide. To wrap the SDK you posted more complex coding is required.
 
Last edited:

Michael2150

Member
Licensed User
Thanks @Biswajit that is a great guide to get me started. I'm experienced enough in Java to at least give it a shot to do myself. I guess ill ask again if I get stuck. Another question would be where would I get the jar files for the SDK.
 

Biswajit

Active Member
Licensed User
Longtime User
Thanks @Biswajit that is a great guide to get me started. I'm experienced enough in Java to at least give it a shot to do myself. I guess ill ask again if I get stuck. Another question would be where would I get the jar files for the SDK.
May be there will be some option to download the SDK on the customer portal. If you check the ios manual integration its written over there to drag and drop the sdk files to the xcode. So there must be some option to download SDK from the customer portal. If not then you can contact them for the SDK files.
 

ThePlankton

Member
Licensed User
Hi so this is my first attempt at making a library for B4a, and a big attempt it is. I have a project that requires the Genius Scan SDK. So after a few days of research I've gone through most of the tutorials on the forum about how to make your own B4a library, and they are all great, but I still can't seem to know where to start when trying to get this going. A little help or push into the right direction from someone a bit more experienced would be helpful.

I have the Eclipse project set up with the B4aShared, Core, android jar files, but that's kinda where I get stuck.
I have a sample project open in Android Studio that shows the SDK at work, it can be found here.
I also have the getting started documentation here.

Thanks.
We're you ever able to complete this library?
 
Top