Java 类android.hardware.ConsumerIrManager 实例源码

项目:IR-Remote    文件:MainActivity.java   
@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)));
}
项目:NezumimiApp    文件:MainActivity.java   
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()));
            }
        }
    }
}
项目:ApkLauncher    文件:ConsumerIr.java   
/**
 * 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);
}
项目:ApkLauncher    文件:ConsumerIr.java   
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());
}
项目:ApiDemos    文件:ConsumerIr.java   
/**
 * 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);
}
项目:ApiDemos    文件:ConsumerIr.java   
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());
}
项目:felix-on-android    文件:ConsumerIr.java   
/**
 * 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);
}
项目:felix-on-android    文件:ConsumerIr.java   
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());
}
项目:irdb-android    文件:ConsumerIrManagerBase.java   
@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;
}
项目: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());

}
项目:react-native-ir-manager    文件:RNIRManagerModule.java   
public RNIRManagerModule(ReactApplicationContext reactContext) {
  super(reactContext);
  manager = (ConsumerIrManager) reactContext.getSystemService(CONSUMER_IR_SERVICE);
}
项目:EasyAndroid    文件:Managers.java   
/**
 * 返回 {@link ConsumerIrManager}
 */
public static ConsumerIrManager getConsumerIrManager()
{
    return (ConsumerIrManager) get(CONSUMER_IR_SERVICE);
}
项目:Android-App-Template    文件:ServiceUtil.java   
@TargetApi(19)
public static ConsumerIrManager getConsumerIrManager() {
    return (ConsumerIrManager) getSystemService(Context.CONSUMER_IR_SERVICE);
}
项目:TVKILL    文件:Transmitter.java   
public void transmit(Context context) {
    ConsumerIrManager IR = (ConsumerIrManager) context.getSystemService(Context.CONSUMER_IR_SERVICE);

    IR.transmit(frequency, pattern);
}
项目:irdb-android    文件:ConsumerIrManagerBase.java   
@SuppressWarnings("ResourceType")
public ConsumerIrManagerBase(Context context) {
    super(context);
    // Get a reference to the ConsumerIrManager
    mCIR = (ConsumerIrManager)context.getSystemService(Context.CONSUMER_IR_SERVICE);
}
项目:irdb-android    文件:ConsumerIrManagerBase.java   
ConsumerIrManager getConsumerIrManager() {
    return mCIR;
}
项目:sprockets-android    文件:Managers.java   
/**
 * @since 4.0.0
 */
public static ConsumerIrManager consumerIr(Context context) {
    return (ConsumerIrManager) context.getSystemService(CONSUMER_IR_SERVICE);
}
项目:android_Skeleton    文件:SystemServices.java   
@TargetApi(AndroidHelper.API_19)
public static ConsumerIrManager consumerIrManager() {
    return (ConsumerIrManager) get(Context.CONSUMER_IR_SERVICE);
}
项目:otrta    文件:KitKatIr.java   
public KitKatIr(Context c) throws Exception{
    mKkIr = (ConsumerIrManager) c.getSystemService(Context.CONSUMER_IR_SERVICE);
    if (!mKkIr.hasIrEmitter()) throw new Exception("No KitKat IR Device");
}
项目:android-wheels    文件:ContextUtils.java   
/**
 * 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));
}