Android Question GetMethod in reflector fails in API 19

touchsquid

Active Member
Licensed User
Longtime User
Android 4.4 has an API for devices with built in IR transmitters such as the HTC One and many Samsung models. I am modifing my app to work with this.

Dim IR As Reflector
IR.target=IR.getcontext
IR.target = IR.RunMethod2("getSystemService", "consumer_ir", "java.lang.String")
if IR.RunMethod("hasIrEmitter") then 'returns true on my HTC one
Dim test As Object = IR.GetMethod("getCarrierFrequencies", types) 'works
test = IR.GetMethod("transmit", Types) 'error java.lang.NoSuchMethodException: transmit []

The above code works up to the last line. The transmit method is documented here:
http://developer.android.com/reference/android/hardware/ConsumerIrManager.html#transmit(int, int[])

If I call the transmit function with Runmethod4 I get the same error. Does anybody know what I might be doing wrong?

IR.Runmethod4 ("transmit", Array As Object(Freq, pattern), Array As String("java.lang.int", "java.lang.int"))


public void transmit (int carrierFrequency, int[] pattern)

Added in API level 19

Transmit and infrared pattern

This method is synchronous; when it returns the pattern has been transmitted. Only patterns shorter than 2 seconds will be transmitted.


Parameters

carrierFrequency The IR carrier frequency in Hertz.
pattern The alternating on/off pattern in microseconds to transmit.
 

touchsquid

Active Member
Licensed User
Longtime User
Thanks Erel,

I have never used JavaObjext. The examples I found don't seem to correspond. Can you give me a hint how to implement the above code?

pattern is an array of integers.
 
Upvote 0

touchsquid

Active Member
Licensed User
Longtime User
Got it working. Don't know why getmethod fails but I left it out and used this code to call transmit:

IR.Runmethod4 ("transmit", Array As Object(Freq, pattern), Array As String("java.lang.int", "[I" ))
 
Upvote 0

Kevin

Well-Known Member
Licensed User
Longtime User
This helped me a lot! I'll contribute a bit to this thread as well, since I didn't realize this until after someone tested it for me:

In order to use this new API you need to add the appropriate permission to your manifest:

android.permission.TRANSMIT_IR
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…