@ReactMethod public void getCarrierFrequencies(Promise promise) { try { CarrierFrequencyRange[] carrierFrequencyRanges = manager.getCarrierFrequencies(); WritableArray carrierFrequencies = Arguments.createArray(); for (CarrierFrequencyRange carrierFrequencyRange : carrierFrequencyRanges) { WritableMap carrierFrequency = Arguments.createMap(); carrierFrequency.putInt("minFrequency", carrierFrequencyRange.getMinFrequency()); carrierFrequency.putInt("maxFrequency", carrierFrequencyRange.getMaxFrequency()); carrierFrequencies.pushMap(carrierFrequency); } promise.resolve(carrierFrequencies); } catch (Exception e) { promise.reject(e); } }
@Override protected void onResume() { super.onResume(); if (DEBUG) Log.d(TAG, "onResume"); irManager = (ConsumerIrManager)getSystemService(CONSUMER_IR_SERVICE); boolean hasIrEmitter = irManager.hasIrEmitter(); Log.d(TAG, "hasIrEmitter=" + hasIrEmitter); if (hasIrEmitter) { CarrierFrequencyRange[] ranges = irManager.getCarrierFrequencies(); for (CarrierFrequencyRange range: ranges) { Log.d(TAG, "range" + ", max=" + range.getMaxFrequency() + ", min=" + range.getMinFrequency() ); } } else { irManager = null; Button button = (Button)findViewById(R.id.button); button.setText("No IrEmitter"); try { Object c = Class.forName("com.lge.hardware.IRBlaster.IRBlaster"); } catch (Exception e) { button.setText(e.toString()); } } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); TextView textView = (TextView)findViewById(R.id.textview); ConsumerIrManager manager = (ConsumerIrManager) getSystemService(CONSUMER_IR_SERVICE); StringBuilder builder = new StringBuilder(); builder.append("ConsumerIrManager.hasIrEmitter()="); builder.append(manager.hasIrEmitter()); Log.d(TAG, "----------------"); Log.d(TAG, builder.toString()); Log.d(TAG, "----------------"); if( manager.hasIrEmitter() == true){ CarrierFrequencyRange[] ranges = manager.getCarrierFrequencies(); for(CarrierFrequencyRange range : ranges){ builder.append(range.getMinFrequency()); builder.append("/"); builder.append(range.getMaxFrequency()); builder.append(" : "); } } textView.setText(builder.toString()); }