@Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.content_main); irManager = (ConsumerIrManager) getSystemService(CONSUMER_IR_SERVICE); findViewById(R.id.tvpower).setOnClickListener(new ClickListener(hex2ir(CMD_TV_POWER))); findViewById(R.id.tvsource).setOnClickListener(new ClickListener(hex2ir(CMD_TV_SOURCE))); findViewById(R.id.tvchnext).setOnClickListener(new ClickListener(hex2ir(CMD_TV_CH_NEXT))); findViewById(R.id.tvchprev).setOnClickListener(new ClickListener(hex2ir(CMD_TV_CH_PREV))); findViewById(R.id.tvback).setOnClickListener(new ClickListener(hex2ir(CMD_TV_BACK))); findViewById(R.id.tvleft).setOnClickListener(new ClickListener(hex2ir(CMD_TV_LEFT))); findViewById(R.id.tvright).setOnClickListener(new ClickListener(hex2ir(CMD_TV_RIGHT))); findViewById(R.id.tvok).setOnClickListener(new ClickListener(hex2ir(CMD_TV_ENTER))); findViewById(R.id.sbpower).setOnClickListener(new ClickListener(hex2ir(CMD_SB_POWER))); findViewById(R.id.sbsource).setOnClickListener(new ClickListener(hex2ir(CMD_SB_SOURCE))); findViewById(R.id.sbvoldown).setOnClickListener(new ClickListener(hex2ir(CMD_SB_VOLDOWN))); findViewById(R.id.sbvolup).setOnClickListener(new ClickListener(hex2ir(CMD_SB_VOLUP))); }
private void checkInfrared() { if (mIrManager.hasIrEmitter()) { if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { // On KitKat, check if we're using 4.4.3+ API int lastIdx = Build.VERSION.RELEASE.lastIndexOf("."); int VERSION_MR = Integer.valueOf(Build.VERSION.RELEASE.substring(lastIdx + 1)); mIsUsingNewApi = (VERSION_MR >= 3); } else { mIsUsingNewApi = true; } ConsumerIrManager.CarrierFrequencyRange[] freqs = mIrManager.getCarrierFrequencies(); if (freqs != null) { for (ConsumerIrManager.CarrierFrequencyRange freq : freqs) { int carrierFreq = MahouCode.getCarrierFrequency(); mCanTransmitCode = ((carrierFreq >= freq.getMinFrequency()) && (carrierFreq <= freq.getMaxFrequency())); } } } }
/** * Initialization of the Activity after it is first created. Must at least * call {@link android.app.Activity#setContentView setContentView()} to * describe what is to be displayed in the screen. */ @Override protected void onCreate(Bundle savedInstanceState) { // Be sure to call the super class. super.onCreate(savedInstanceState); // Get a reference to the ConsumerIrManager mCIR = (ConsumerIrManager)getSystemService(Context.CONSUMER_IR_SERVICE); // See assets/res/any/layout/consumer_ir.xml for this // view layout definition, which is being set here as // the content of our screen. setContentView(R.layout.consumer_ir); // Set the OnClickListener for the button so we see when it's pressed. findViewById(R.id.send_button).setOnClickListener(mSendClickListener); findViewById(R.id.get_freqs_button).setOnClickListener(mGetFreqsClickListener); mFreqsText = (TextView) findViewById(R.id.freqs_text); }
public void onClick(View v) { StringBuilder b = new StringBuilder(); if (!mCIR.hasIrEmitter()) { mFreqsText.setText("No IR Emitter found!"); Log.e(TAG, "No IR Emitter found!\n"); return; } // Get the available carrier frequency ranges ConsumerIrManager.CarrierFrequencyRange[] freqs = mCIR.getCarrierFrequencies(); b.append("IR Carrier Frequencies:\n"); for (ConsumerIrManager.CarrierFrequencyRange range : freqs) { b.append(String.format(" %d - %d\n", range.getMinFrequency(), range.getMaxFrequency())); } mFreqsText.setText(b.toString()); }
@Override public CarrierFrequencyRange[] getCarrierFrequencies() { CarrierFrequencyRange[] result = null; if(mCIR!=null) { ConsumerIrManager.CarrierFrequencyRange[] ranges = mCIR.getCarrierFrequencies(); result = new CarrierFrequencyRange[ranges.length]; int n=0; for (ConsumerIrManager.CarrierFrequencyRange range : ranges) { result[n++] = new CarrierFrequencyRange(range.getMinFrequency(), range.getMaxFrequency()); } } return result; }
@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()); }
public RNIRManagerModule(ReactApplicationContext reactContext) { super(reactContext); manager = (ConsumerIrManager) reactContext.getSystemService(CONSUMER_IR_SERVICE); }
/** * 返回 {@link ConsumerIrManager} */ public static ConsumerIrManager getConsumerIrManager() { return (ConsumerIrManager) get(CONSUMER_IR_SERVICE); }
@TargetApi(19) public static ConsumerIrManager getConsumerIrManager() { return (ConsumerIrManager) getSystemService(Context.CONSUMER_IR_SERVICE); }
public void transmit(Context context) { ConsumerIrManager IR = (ConsumerIrManager) context.getSystemService(Context.CONSUMER_IR_SERVICE); IR.transmit(frequency, pattern); }
@SuppressWarnings("ResourceType") public ConsumerIrManagerBase(Context context) { super(context); // Get a reference to the ConsumerIrManager mCIR = (ConsumerIrManager)context.getSystemService(Context.CONSUMER_IR_SERVICE); }
ConsumerIrManager getConsumerIrManager() { return mCIR; }
/** * @since 4.0.0 */ public static ConsumerIrManager consumerIr(Context context) { return (ConsumerIrManager) context.getSystemService(CONSUMER_IR_SERVICE); }
@TargetApi(AndroidHelper.API_19) public static ConsumerIrManager consumerIrManager() { return (ConsumerIrManager) get(Context.CONSUMER_IR_SERVICE); }
public KitKatIr(Context c) throws Exception{ mKkIr = (ConsumerIrManager) c.getSystemService(Context.CONSUMER_IR_SERVICE); if (!mKkIr.hasIrEmitter()) throw new Exception("No KitKat IR Device"); }
/** * Obtain a {@link ConsumerIrManager} instance associated with specified {@link Context} * * @param context Context * @return {@link ConsumerIrManager} associated with specified {@link Context} * @throws InvalidContextException if {@link ConsumerIrManager} can't be obtained * from specified {@link Context} */ @NonNull @RequiresApi(Build.VERSION_CODES.KITKAT) public static ConsumerIrManager getConsumerIrManager(@NonNull Context context) { return validate(context.getSystemService(Context.CONSUMER_IR_SERVICE)); }