Android Radio实战——切换电台(九)

        这里切换电台,首先要知道对应电台信息,然后传入对应的电台信息进行电台跳转。应用场景为电台列表、收藏列表中点击切换,还有搜索到有效电台后通过该方法跳转到指定电台。

一、Java层调用

1、方法封装

private static final String KEYVALUEPAIRS_AM = "tuner_band=am";
private static final String KEYVALUEPAIRS_FM = "tuner_band=fm";

public void setRadioCurChannelInfo(int[] channelInfo) {
    synchronized (mLock) {
        if (mRadioTuner == null) {
            mRadioTuner = openSession(mRadioCallback);
        }
        if (channelInfo.length >= CHANNEL_INFO_SIZE) {
            int freq = channelInfo[0];
            int band = channelInfo[1];
            if (mCurrentBand != band) {
                mAudioManager.setParameters(band == TYPE_FM ? KEYVALUEPAIRS_FM : KEYVALUEPAIRS_AM);
            }
            if (band == TYPE_FM) {
                band = RadioManager.BAND_FM;
            } else if (band == TYPE_AM) {

你可能感兴趣的:(Android,Radio开发,android,Radio开发)