Java 类android.hardware.ConsumerIrManager.CarrierFrequencyRange 实例源码

项目:react-native-ir-manager    文件:RNIRManagerModule.java   
@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);
    }

}
项目:Simplicissimus    文件:Sample.java   
@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());
        }
    }
}
项目:IR-blaster-sample    文件:MainActivity.java   
@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());

}