Android Question Does using library ".so" with B4A?

vecino

Well-Known Member
Licensed User
Longtime User
Hi, I'm doing a software sales for a POS.

This POS consists of several components: a tablet, a printer, a rear display, etc.

All software supplied by the manufacturer (drivers, libraries, etc..) Is written in java.

In the android system, in the "lib" directory is: libAclasArmPos.so

The manufacturer gives a demo where I can find, among others, the following:
printer.java
drawer.java
rfid.java
etc.

There are demos as:
AclasDrawerActrivity.java
AclasPrinterActivity.java
AclasRfidActivity.java
etc.

And classes, including:
printer.class
drawer.class
rfid.class
etc.

For example, printer.java is:
B4X:
package aclasdriver;
public class printer {
  public native int Open();
  public native void Close();
  public native int Write(byte[] wrbuf);
  public native byte[] Read(int getlen);
  public native int SetContrast(int contrast);
  public native int Feed(int setp);
  public native int Stop();
  public native int Conitnue();
  public native int GetDotWidth();
  public native int SetPrintMode(int Mode); //
  public native boolean IsPaperExist();
  static {
  System.loadLibrary("AclasArmPos");
  }
}

I do not know the java language and so my question:

Is it possible to use libAclasArmPos.so or how can I get that code with B4A?

Thank you very much and regards.
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
I think you can not import a library directly in b4a. You can have a b4a wrapper lib which then includes the imported java lib.
BUT you need to have such wrapper and you have to find someone who wrote it, Or you search the forum about "how to creating a wrapperlib with exclipse" for b4a and write it by your own
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
I think you can not import a library directly in b4a. You can have a b4a wrapper lib which then includes the imported java lib.
BUT you need to have such wrapper and you have to find someone who wrote it, Or you search the forum about "how to creating a wrapperlib with exclipse" for b4a and write it by your own

I have gone cold sweats. I have no idea how to do that. You've put the fear in the body.
I do not know what you have translated the "translate.google", so I put it in Spanish :)
Me han entrado sudores frios. No tengo ni idea de cómo hacer eso. Me has metido el miedo en el cuerpo.
Anyway, the question is: Who B4A, how to write to a serial printer?

Thanks and regards
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I have gone cold sweats. I have no idea how to do that. You've put the fear in the body.
I do not know what you have translated the "translate.google", so I put it

I think i have understand what you wanted to say. :) Sorry about this but i cannot write such a wrapper too. I would feel the same i think if i need a wrapper which does not exists :(

If it is an serial-printer then you should be able to communicate with it with the serial-lib?
How to communicate with the printer over serial should be explained in the documentation?
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Hi, thanks for replying :)

The POS comes with java source code that I mentioned before and a demo.
In addition to the library ".so" and no more.

I'm desperate, I thought it would be easy printer and left it for the end, now the whole project is finished but I can not print: (
Regards.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
By the way, although I have written before "serial printer" really do not know, it can be USB printer.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
Sounds like the printer manufacturer has supplied you with an SDK that contains:
  • C or C++ .so library file(s).
  • Java classes that expose the C or C++ library to java.
    The printer.java class you posted is an example of one of these classes.
  • Example android java application(s).

You might find this page useful:
http://developer.android.com/training/articles/perf-jni.html

In order to use the SDK in B4A you need to create new java classes that wrap the existing java classes.
These new java classes become B4A objects and have methods and properties that interact with the existing java classes.
You'd create a new java project with say Eclipse, add the .so library files and existing java classes and then create these new java classes.

When compiled you'd end up with a B4A .jar library file containing everything from the java project.

This probably isn't a particularly difficult task but would be pretty time consuming.
And would require at least basic knowledge of the java language.

You best bet would be to post in the Android Job Offers - that is of course if you can afford to pay someone to do the work...

Martin.
 
Upvote 0

vecino

Well-Known Member
Licensed User
Longtime User
Thanks for the information.

I never thought it was so complicated to print using B4A.

Regards.
 
Upvote 0
Top