Android Question How do I perform type conversion?

jarda

Member
Licensed User
Longtime User
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:

jarda

Member
Licensed User
Longtime User
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:
Upvote 0

jarda

Member
Licensed User
Longtime User
Erel,

Author library translated it using Simple Library Compiler
xml and jar file and sent me
 
Upvote 0

jarda

Member
Licensed User
Longtime User
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

jarda

Member
Licensed User
Longtime User
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

jarda

Member
Licensed User
Longtime User
Hi Erel

code in java


1. from the library
send.png


2. inside the library

write.png
 
Upvote 0

jarda

Member
Licensed User
Longtime User
Hi Erel

I need to solve the handover byte [] data.
Only..
 

Attachments

  • Untitled-1.png
    Untitled-1.png
    185.4 KB · Views: 156
Upvote 0

jarda

Member
Licensed User
Longtime User
Hi Erel

When you declare a single byte
 

Attachments

  • Untitled-2.png
    Untitled-2.png
    190.4 KB · Views: 131
Last edited:
Upvote 0
Top