touchsquid Active Member Licensed User Longtime User Jan 13, 2014 #1 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.
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.
Erel B4X founder Staff member Licensed User Longtime User Jan 13, 2014 #2 Your code is incorrect. The second parameter is an array of ints not int. I recommend you to use JavaObject instead of Reflection. It will be easier to implement it. Upvote 0
Your code is incorrect. The second parameter is an array of ints not int. I recommend you to use JavaObject instead of Reflection. It will be easier to implement it.
touchsquid Active Member Licensed User Longtime User Jan 13, 2014 #3 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
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.
touchsquid Active Member Licensed User Longtime User Jan 13, 2014 #4 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
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" ))
Kevin Well-Known Member Licensed User Longtime User Jan 18, 2014 #5 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
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