我正在使用Barcode Scanner。当我点击扫描按钮时,获得以下异常。
07-05 16:15:50.328:E / AndroidRuntime(301):android.content.ActivityNotFoundException:找不到处理Intent的活动{act = com.google.zxing.client.android.SCAN(有附加内容)}
这是我的代码:
getWindow().setFormat(PixelFormat.UNKNOWN);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
scan_btn.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent scanIntent= new Intent("com.google.zxing.client.android.SCAN");
scanIntent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(scanIntent, 0);
if(!previewing){
camera = Camera.open();
if (camera != null){
try {
camera.setPreviewDisplay(surfaceHolder);
camera.startPreview();
previewing = true;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
});
}
public void onActivityResult(int requestCode, int resultCode, Intent intent) {
if (requestCode == 0) {
if (resultCode == RESULT_OK) {
String contents = intent.getStringExtra("SCAN_MODE");
String format = intent.getStringExtra("SCAN_RESULT_FORMAT");
// Handle successful scan
result_text.setText(intent.getStringExtra("SCAN_RESULT"));
} else if (resultCode == RESULT_CANCELED) {
// Handle cancel
result_text.setText("Scan cancelled.");
}
}
}
@Override
public void surfaceCreated(SurfaceHolder paramSurfaceHolder) {
// TODO Auto-generated method stub
}
@Override
public void surfaceChanged(SurfaceHolder paramSurfaceHolder, int paramInt1,
int paramInt2, int paramInt3) {
// TODO Auto-generated method stub
}
@Override
public void surfaceDestroyed(SurfaceHolder paramSurfaceHolder) {
// TODO Auto-generated method stub
}
}
我在清单文件中注册了captureActivity。
答案 0 :(得分:1)
我认为你应该关注this。
答案 1 :(得分:-1)
如果你正在与Zxing整合,请确保你的Manifest中有这个:
<activity android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
你还需要将它发送给调用意图:
intent.setPackage(yourpackagestring);