implementation of main class:
public class Main Activity extends Activity implements ZBarScannerView.ResultHandler {
private ZBarScannerView mscannerview ;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void onClick1(View view){
mscannerview=new ZBarScannerView(this);
setContentView(mscannerview);
mscannerview.setResultHandler(this);
mscannerview.startCamera();
}
@Override public void onPause() {
super.onPause();
mscannerview.stopCamera();
}
@Override public void handleResult(Result result) {
Log.w("handleResult", result.getContents());
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Scan result");
builder.setMessage(result.getContents());
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
}
錯誤:1月2日至一十八日:42:51.809 14705-14851/com.anewapplication W/CameraBase:0相機無法正常工作掃描
它是一種簡單的實現:在連接到相機時發生錯誤的Zbar庫和我的相機不會彈出掃描!幫幫我 !提前致謝。
發佈錯誤日誌... – rafsanahmad007
你在哪裏註冊的單擊事件?你能分享完整的Activity類代碼和錯誤日誌嗎? – rahul
嘗試刪除行'setContentView(mScannerView)'。這條線是什麼?錯誤日誌? – imaadhrizni