Android Radio实战——获取频道信息(八)

一、Java层调用

1、方法封装

private static final int SIGNALSTRENGTH_WEAK = 0;
private static final int SIGNALSTRENGTH_STRONG = 1;
private static final int TYPE_FM = 0;
private static final int TYPE_AM = 1;

public int[] getRadioCurChannelInfo() {
    if (mRadioTuner == null) {
        mRadioTuner = openSession(mRadioCallback);
    }

    RadioManager.ProgramInfo[] info = new RadioManager.ProgramInfo[1];
    if (mRadioTuner.getProgramInformation(info) == RadioManager.STATUS_OK) {
        int freq = info[0].getChannel();
        // 获取信号强度
        int signalStrength = SIGNALSTRENGTH_STRONG;
        if (info[0].getSignalStrength() == SIGNALSTRENTTH_WEAK_HAL) {
            signalStrength = SIGNALSTRENGTH_WEAK;
        } else if (info[0].getSignalStrength() == SIGNALSTRENGTH_STRONG_HAL) {
            signalStrength = SIGNALSTRENGTH_STRONG;
        } else {
            Log.e(TAG, 

猜你喜欢

转载自blog.csdn.net/c19344881x/article/details/130747482
今日推荐