构造函数BeepManager(Activity)不可见

时间:2015-11-18 07:31:39

标签: java android

我已将zxing lib com.google/com.google.zxing.client.android.captureactivity.jar.zip(497 k)导入到我的项目中。 然后我以这种方式在我的项目中有一个imporgted BeepManager类:

import com.google.zxing.client.android.BeepManager;
private BeepManager beepManager;
beepManager = new BeepManager(activity);

在import语句之后,我有这个错误提示:

The constructor BeepManager(Activity) is not visible

编辑:

DecodeHandler(CaptureActivity activity) {
        this.activity = activity;
        baseApi = activity.getBaseApi();
        beepManager = new BeepManager(CaptureActivity.this);
        beepManager.updatePrefs();

请问可能出错......

1 个答案:

答案 0 :(得分:0)

尝试改变这一点:

beepManager = new BeepManager(activity);

对此:

beepManager = new BeepManager(<ActivityName>.this);

编辑:问题出现了,因为您正在Class的实例上发送类标识符,您可以通过更改它来解决它:

DecodeHandler(CaptureActivity activity) {
        this.activity = activity;
        baseApi = activity.getBaseApi();
        beepManager = new BeepManager(CaptureActivity.this);
        beepManager.updatePrefs();

DecodeHandler(CaptureActivity activity) {
        this.activity = activity;
        baseApi = activity.getBaseApi();
        beepManager = new BeepManager(activity);
        beepManager.updatePrefs();