J jarda Member Licensed User Longtime User Aug 27, 2014 #1 Hi all I have a library with variable declaration type android.os.Handler How to use it in b4a? for example. Dim a As android.os.Handler ?! in the library is (third-party library.jar and library.xml) library.xml has ........... <method> <name>Init</name> <returntype>void</returntype> <parameter> <name>context</name> <type>android.content.Context</type> </parameter> <parameter> <name>handler</name> <type>android.os.Handler</type> </parameter> </method> ............................. Dim handler As android.os.Handler Init(context, handler ) handler should return values SUCCESS FAILED CLOSED Thanks for the advice Last edited: Aug 27, 2014
Hi all I have a library with variable declaration type android.os.Handler How to use it in b4a? for example. Dim a As android.os.Handler ?! in the library is (third-party library.jar and library.xml) library.xml has ........... <method> <name>Init</name> <returntype>void</returntype> <parameter> <name>context</name> <type>android.content.Context</type> </parameter> <parameter> <name>handler</name> <type>android.os.Handler</type> </parameter> </method> ............................. Dim handler As android.os.Handler Init(context, handler ) handler should return values SUCCESS FAILED CLOSED Thanks for the advice
J jarda Member Licensed User Longtime User Aug 27, 2014 #2 one more question to conversion XML has the following definition: <method> <name>sendByteData</name> <returntype>int</returntype> <parameter> <name>data[]</name> <type>byte</type> </parameter> </method> 1. if I give in B4a Dim data() As byte sendByteData(data) compiler writes : error: inconvertible types sendByteData((byte)(_data)); required: byte found: byte[] 1 error --------------------- 2. if I give in B4a Dim data As byte sendByteData(data) compiler writes : required: byte[] found: byte reason: actual argument byte cannot be converted to byte[] by method invocation conversion 1 error Note Erel said in ...... Basic4android byte() is identical to Java byte[]. (http://www.b4x.com/android/forum/threads/return-byte-from-external-library.15527/#content) Does anybody know how to do it ? Last edited: Aug 27, 2014 Upvote 0
one more question to conversion XML has the following definition: <method> <name>sendByteData</name> <returntype>int</returntype> <parameter> <name>data[]</name> <type>byte</type> </parameter> </method> 1. if I give in B4a Dim data() As byte sendByteData(data) compiler writes : error: inconvertible types sendByteData((byte)(_data)); required: byte found: byte[] 1 error --------------------- 2. if I give in B4a Dim data As byte sendByteData(data) compiler writes : required: byte[] found: byte reason: actual argument byte cannot be converted to byte[] by method invocation conversion 1 error Note Erel said in ...... Basic4android byte() is identical to Java byte[]. (http://www.b4x.com/android/forum/threads/return-byte-from-external-library.15527/#content) Does anybody know how to do it ?
Erel B4X founder Staff member Licensed User Longtime User Aug 27, 2014 #3 It will not work. You cannot create an XML for a library that was not written specifically for B4A. You will need to create a wrapper library that calls this library. Upvote 0
It will not work. You cannot create an XML for a library that was not written specifically for B4A. You will need to create a wrapper library that calls this library.
J jarda Member Licensed User Longtime User Aug 27, 2014 #4 Thank you for your answer Applies to android.os.Handler or Dim data () As Byte Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Aug 27, 2014 #5 It was a general statement. The byte is not problematic. According to the error message you should have passed a single byte instead of an array of bytes. Upvote 0
It was a general statement. The byte is not problematic. According to the error message you should have passed a single byte instead of an array of bytes.
J jarda Member Licensed User Longtime User Aug 27, 2014 #6 Erel, Author library translated it using Simple Library Compiler xml and jar file and sent me Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Aug 27, 2014 #7 As I wrote, it will not work. You cannot directly create a handler in B4A or a context. If the library is not too complicated than it will be easier to access it with JavaObject. Upvote 0
As I wrote, it will not work. You cannot directly create a handler in B4A or a context. If the library is not too complicated than it will be easier to access it with JavaObject.
J jarda Member Licensed User Longtime User Aug 27, 2014 #8 It's all prepared for B4a There are only two things that do not go You have no idea how to solve it? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Aug 28, 2014 #9 Ask the author to send you a java example that uses this code. Upvote 0
J jarda Member Licensed User Longtime User Sep 2, 2014 #10 Hi Erel code example how to call in JAVA private TimerTask myTask = new TimerTask() { byte[] writeData = new byte[] { 0x10, 0x04, 0x01 }; @override public void run() { if (mPrinter == null) { timer.cancel(); return; } mPrinter.sendByteData(writeData); if (mPrinter.read() != null) { System.out.println("wifi connection is alive.."); } else { errorNumber++; if (errorNumber == 2) { errorNumber = 0; close(); } } } }; Upvote 0
Hi Erel code example how to call in JAVA private TimerTask myTask = new TimerTask() { byte[] writeData = new byte[] { 0x10, 0x04, 0x01 }; @override public void run() { if (mPrinter == null) { timer.cancel(); return; } mPrinter.sendByteData(writeData); if (mPrinter.read() != null) { System.out.println("wifi connection is alive.."); } else { errorNumber++; if (errorNumber == 2) { errorNumber = 0; close(); } } } };
Erel B4X founder Staff member Licensed User Longtime User Sep 3, 2014 #11 It is missing the code that creates mPrinter. Upvote 0
J jarda Member Licensed User Longtime User Sep 3, 2014 #12 I know, I'm waiting for the answer Upvote 0
J jarda Member Licensed User Longtime User Sep 4, 2014 #13 Hi Erel code in java 1. from the library 2. inside the library Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Sep 4, 2014 #14 This code doesn't show how myPrinter is created. Upvote 0
J jarda Member Licensed User Longtime User Sep 4, 2014 #15 Hi Erel I need to solve the handover byte [] data. Only.. Attachments Untitled-1.png 185.4 KB · Views: 375 Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Sep 4, 2014 #16 Based on the error this method expects a single byte, not an array of bytes. Upvote 0
J jarda Member Licensed User Longtime User Sep 4, 2014 #17 Hi Erel When you declare a single byte Attachments Untitled-2.png 190.4 KB · Views: 381 Last edited: Sep 4, 2014 Upvote 0