java - 将java文件更改为android的问题

标签 java android netbeans

我有一个在netbeans中创建的java项目,现在我试图将其更改为eclipse中的android项目,但它显示了很多错误。请有人帮我解决错误

public abstract class BaseOutputAudioDevice extends AudioDeviceBase {
private Logger log = Logger.getLogger(BaseOutputAudioDevice.class.getName());

protected int position = 0;
protected int freq;
protected int channels;
protected int samplesPerMillisecond;
protected boolean init = false;
protected SampleProcessor processor;

public BaseOutputAudioDevice(SampleProcessor processor) {
    this.processor = processor;
}

@Override
protected void openImpl() throws JavaLayerException {
    super.openImpl();
}

@Override
protected void writeImpl(short[] samples, int offs, int len) throws JavaLayerException {
    if(!init)
    {
        log.log(Level.INFO, "number of channels: " + getDecoder().getOutputChannels());
        log.log(Level.INFO, "number of samples: " + getDecoder().getOutputFrequency());
        freq = getDecoder().getOutputFrequency();
        channels = getDecoder().getOutputChannels();
        samplesPerMillisecond = (freq * channels)/1000;
        log.log(Level.INFO, "samples/ms: " + samplesPerMillisecond);
        log.log(Level.INFO, "buffer length: " + len);
        if(processor != null)
            processor.init(freq, channels);
        init = true;
    }
    position += len/samplesPerMillisecond;

    outputImpl(samples, offs, len);
}

protected abstract void outputImpl(short[] samples, int offs, int len) throws JavaLayerException;

/**
 * Retrieves the current playback position in milliseconds.
*/
public int getPosition() {
    log.log(Level.FINE, "position: " + position + "ms");
    return position;
}

public SampleProcessor getProcessor() {
    return processor;
}

public void setProcessor(SampleProcessor processor) {
    this.processor = processor;
}
}

编辑

它显示以下行中的错误

log.log(Level.INFO, "number of channels: " + getDecoder().getOutputChannels());
log.log(Level.INFO, "number of samples: " + getDecoder().getOutputFrequency());
freq = getDecoder().getOutputFrequency();
channels = getDecoder().getOutputChannels();

最佳答案

您正在尝试使用 Android 上不存在的库。 例如,您的 log.log 行看起来很像 Log4J 调用。 您需要隔离这些行并使用它们的 Android 等效项。 在 Log4J 示例中 - 尝试使用 Android 记录器。

关于java - 将java文件更改为android的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5220250/

相关文章:

android - JNIEnv 全局引用与 C 中的 jobject 有何不同?

java - 如何在没有 EventListener 的情况下以编程方式在 JList 中添加元素?

java - JAX-RS 资源错误 : Couldn't find JAX-B element for class java. lang.String 和更多异常

android - 如何在 Kotlin 中合并流和 channel ?

android - 如何创建同时支持手机和平板电脑的应用程序?

Java自动装箱

java - 无需 Webview 即可集成 Google 云打印

java - 无法使 jTable 不可见

java - 销毁 Activity 时保存一个值,然后恢复它

java - 在Java中使用ObjectInputStream/ObjectOutputStream实现网络 "packets"的优点和缺点?