Android 4.4 ConsumerIr.transmit变得疯狂

时间:2014-01-24 00:56:26

标签: java android api android-4.4-kitkat infrared

我正在尝试编写一个Android应用程序,该应用程序利用Android 4.4 KitKat中添加的新红外API。 →Documentation

我遇到了麻烦,因为我的应用程序因为没有响应而冻结并被杀死。

一些代码:

...
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    irService = (ConsumerIrManager) getSystemService(CONSUMER_IR_SERVICE);
    Log.d("transmit", "lets go");
    irService.transmit(38000, new int[] { 70 });
    Log.d("transmit", "done");
...

这个logcat:

01-24 01:28:25.450: D/transmit(10551): lets go
01-24 01:29:14.610: D/transmit(10551): done

传输呼叫需要超过30秒!

来自文档:

public void transmit (int carrierFrequency, int[] pattern)
Added in API level 19

Tansmit 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. <---- this is wrong, see http://stackoverflow.com/questions/20244337

通过我的手机相机我看到红外LED一直闪烁,所以我用红外传感器测量实际传输时间(+表示爆发, - 表示空间):

+64
-88448
+1835
-789
+1557
-768
+1579
-768
+1579
-768
+149
-491
+1664
-555
+533
-555
+1664
-555
+1664
-555
+1664
-555
+533
-555
+533
-555
+533
-555
+533
-533
+555
-555
+533
-555
+533
-555
+533
-555
+533
-555
+1664
-555
+1664
-555
+533
-555
+533
-555
+533
-555
+533
-555
+533
-555
+1664
-555
+533
-555
+533
-555
+1664
-555
+1664
-555
+1664
-555
+1664
-555
+1664
-555
+555
-388053
+60672
-384
+341
-714709
+61419
-320
+277
-533
+213
-1188181
+42069
-491
+299
-733269
+38421
-427
+341
-736917
+38208
-427
+320
-737131
+37867
-491
+320
-737429
+37696
-512
+299
-737600
+37739
-597
+256
-737536
+36736
-533
+320
-1213376
+36181
-683
+235
-739008
+35605
-789
+213
-1214336
+36181
-683
+256
-1213824
+36651
-576
+277
-1213440
+36160
-619
+277
-1213930
+35797
-555
+320
-1214272
+36480
-555
+299

怎么回事?

我的设备是运行OnmiROM 4.4 android的Galaxy Note 10.1 N8010。也许拥有兼容设备的人可以测试一下吗?

1 个答案:

答案 0 :(得分:0)

好的,在为我的设备更新OmniROM版本后,问题得到解决。