public class CaptureHelper extends java.lang.Object implements CaptureLifecycle, CaptureTouchEvent, CaptureManager
| 构造器和说明 |
|---|
CaptureHelper(Activity activity,
SurfaceView surfaceView,
ViewfinderView viewfinderView)
已过时。
|
CaptureHelper(Activity activity,
SurfaceView surfaceView,
ViewfinderView viewfinderView,
View ivTorch) |
CaptureHelper(androidx.fragment.app.Fragment fragment,
SurfaceView surfaceView,
ViewfinderView viewfinderView)
已过时。
|
CaptureHelper(androidx.fragment.app.Fragment fragment,
SurfaceView surfaceView,
ViewfinderView viewfinderView,
View ivTorch) |
| 限定符和类型 | 方法和说明 |
|---|---|
CaptureHelper |
autoRestartPreviewAndDecode(boolean isAutoRestartPreviewAndDecode)
设置是否自动重启扫码和解码器,当支持连扫时才起作用。
|
CaptureHelper |
brightEnoughLux(float brightEnoughLux)
设置光线足够明亮时,自动隐藏手电筒按钮
|
CaptureHelper |
characterSet(java.lang.String characterSet)
设置解码时编码字符集
|
CaptureHelper |
continuousScan(boolean isContinuousScan)
设置是否连续扫码,如果想支持连续扫码,则将此方法返回
true并重写onResult(Result) |
CaptureHelper |
decodeFormats(java.util.Collection<com.google.zxing.BarcodeFormat> decodeFormats)
设置支持的解码一/二维码格式,默认常规的码都支持
|
CaptureHelper |
decodeHint(com.google.zxing.DecodeHintType key,
java.lang.Object value)
DecodeHintType |
CaptureHelper |
decodeHints(java.util.Map<com.google.zxing.DecodeHintType,java.lang.Object> decodeHints)
DecodeHintType |
CaptureHelper |
framingRectHorizontalOffset(int framingRectHorizontalOffset)
设置识别区域水平方向偏移量,非全屏识别时才有效
|
CaptureHelper |
framingRectRatio(float framingRectRatio)
设置识别区域比例,范围建议在0.625 ~ 1.0之间。
|
CaptureHelper |
framingRectVerticalOffset(int framingRectVerticalOffset)
设置识别区域垂直方向偏移量,非全屏识别时才有效
|
CaptureHelper |
frontLightMode(FrontLightMode mode)
设置闪光灯模式。
|
CaptureHelper |
fullScreenScan(boolean fullScreenScan)
设置是否支持全屏扫码识别
|
com.king.zxing.AmbientLightManager |
getAmbientLightManager()
AmbientLightManager |
BeepManager |
getBeepManager()
|
CameraManager |
getCameraManager()
|
com.king.zxing.InactivityTimer |
getInactivityTimer()
InactivityTimer |
void |
onCreate()
Activity#onCreate(Bundle) |
void |
onDestroy()
Activity#onDestroy() |
void |
onPause()
Activity#onPause() |
void |
onResult(com.google.zxing.Result result)
';, mnb
接收扫码结果,想支持连扫时,可将
continuousScan(boolean)设置为true
如果isContinuousScan支持连扫,则默认重启扫码和解码器;当连扫逻辑太复杂时,
请将autoRestartPreviewAndDecode(boolean)设置为false,并手动调用restartPreviewAndDecode() |
void |
onResult(com.google.zxing.Result result,
Bitmap barcode,
float scaleFactor)
接收扫码结果
|
void |
onResume()
Activity#onResume() |
boolean |
onTouchEvent(MotionEvent event)
支持缩放时,须在
Activity#onTouchEvent(MotionEvent)调用此方法 |
CaptureHelper |
playBeep(boolean playBeep)
设置是否播放音效
|
void |
restartPreviewAndDecode()
重新启动扫码和解码器
|
CaptureHelper |
returnBitmap(boolean returnBitmap)
设置返回扫码原图
|
CaptureHelper |
setOnCaptureCallback(OnCaptureCallback callback)
设置扫码回调
|
CaptureHelper |
supportAutoZoom(boolean supportAutoZoom)
设置是否支持自动缩放
|
CaptureHelper |
supportLuminanceInvert(boolean supportLuminanceInvert)
是否支持识别反色码,黑白颜色反转
|
CaptureHelper |
supportVerticalCode(boolean supportVerticalCode)
设置是否支持扫垂直的条码
|
CaptureHelper |
supportZoom(boolean supportZoom)
设置是否支持缩放
|
void |
surfaceChanged(SurfaceHolder holder,
int format,
int width,
int height) |
void |
surfaceCreated(SurfaceHolder holder) |
void |
surfaceDestroyed(SurfaceHolder holder) |
CaptureHelper |
tooDarkLux(float tooDarkLux)
设置光线太暗时,自动显示手电筒按钮
|
CaptureHelper |
vibrate(boolean vibrate)
设置是否震动
|
@Deprecated
public CaptureHelper(androidx.fragment.app.Fragment fragment,
SurfaceView surfaceView,
ViewfinderView viewfinderView)
fragment - surfaceView - viewfinderView - public CaptureHelper(androidx.fragment.app.Fragment fragment,
SurfaceView surfaceView,
ViewfinderView viewfinderView,
View ivTorch)
@Deprecated
public CaptureHelper(Activity activity,
SurfaceView surfaceView,
ViewfinderView viewfinderView)
activity - surfaceView - viewfinderView - public CaptureHelper(Activity activity,
SurfaceView surfaceView,
ViewfinderView viewfinderView,
View ivTorch)
activity - surfaceView - viewfinderView - ivTorch - public void onCreate()
CaptureLifecycleActivity#onCreate(Bundle)onCreate 在接口中 CaptureLifecyclepublic void onResume()
CaptureLifecycleActivity#onResume()onResume 在接口中 CaptureLifecyclepublic void onPause()
CaptureLifecycleActivity#onPause()onPause 在接口中 CaptureLifecyclepublic void onDestroy()
CaptureLifecycleActivity#onDestroy()onDestroy 在接口中 CaptureLifecyclepublic boolean onTouchEvent(MotionEvent event)
Activity#onTouchEvent(MotionEvent)调用此方法onTouchEvent 在接口中 CaptureTouchEventevent - public void surfaceCreated(SurfaceHolder holder)
public void surfaceChanged(SurfaceHolder holder,
int format,
int width,
int height)
public void surfaceDestroyed(SurfaceHolder holder)
public void restartPreviewAndDecode()
public void onResult(com.google.zxing.Result result,
Bitmap barcode,
float scaleFactor)
result - barcode - scaleFactor - public void onResult(com.google.zxing.Result result)
continuousScan(boolean)设置为true
如果isContinuousScan支持连扫,则默认重启扫码和解码器;当连扫逻辑太复杂时,
请将autoRestartPreviewAndDecode(boolean)设置为false,并手动调用restartPreviewAndDecode()result - 扫码结果public CaptureHelper continuousScan(boolean isContinuousScan)
true并重写onResult(Result)public CaptureHelper autoRestartPreviewAndDecode(boolean isAutoRestartPreviewAndDecode)
public CaptureHelper playBeep(boolean playBeep)
public CaptureHelper vibrate(boolean vibrate)
public CaptureHelper supportZoom(boolean supportZoom)
supportZoom - public CaptureHelper decodeFormats(java.util.Collection<com.google.zxing.BarcodeFormat> decodeFormats)
decodeFormats - 可参见DecodeFormatManagerpublic CaptureHelper decodeHints(java.util.Map<com.google.zxing.DecodeHintType,java.lang.Object> decodeHints)
DecodeHintTypedecodeHints - public CaptureHelper decodeHint(com.google.zxing.DecodeHintType key, java.lang.Object value)
DecodeHintTypekey - DecodeHintTypevalue - public CaptureHelper characterSet(java.lang.String characterSet)
characterSet - public CaptureHelper supportVerticalCode(boolean supportVerticalCode)
supportVerticalCode - 默认为false,想要增强扫条码识别度时可使用,相应的会增加性能消耗。public CaptureHelper frontLightMode(FrontLightMode mode)
FrontLightMode.AUTO时,如果满意默认的照度值范围,
可通过tooDarkLux(float)和brightEnoughLux(float)来自定义照度范围,
控制自动触发开启和关闭闪光灯。
当设置模式非FrontLightMode.AUTO时,传感器不会检测,则不使用手电筒mode - 默认:FrontLightMode.AUTOpublic CaptureHelper tooDarkLux(float tooDarkLux)
tooDarkLux - 默认:AmbientLightManager.TOO_DARK_LUXpublic CaptureHelper brightEnoughLux(float brightEnoughLux)
brightEnoughLux - 默认:AmbientLightManager.BRIGHT_ENOUGH_LUXpublic CaptureHelper returnBitmap(boolean returnBitmap)
returnBitmap - 默认为false,当返回true表示扫码就结果会返回扫码原图,相应的会增加性能消耗。public CaptureHelper supportAutoZoom(boolean supportAutoZoom)
supportAutoZoom - public CaptureHelper supportLuminanceInvert(boolean supportLuminanceInvert)
supportLuminanceInvert - 默认为false,当返回true时表示支持,会增加识别率,但相应的也会增加性能消耗。public CaptureHelper fullScreenScan(boolean fullScreenScan)
fullScreenScan - 默认为falsepublic CaptureHelper framingRectRatio(float framingRectRatio)
framingRectRatio - 默认0.9public CaptureHelper framingRectVerticalOffset(int framingRectVerticalOffset)
framingRectVerticalOffset - 默认0,表示不偏移public CaptureHelper framingRectHorizontalOffset(int framingRectHorizontalOffset)
framingRectHorizontalOffset - 默认0,表示不偏移public CaptureHelper setOnCaptureCallback(OnCaptureCallback callback)
callback - public CameraManager getCameraManager()
getCameraManager 在接口中 CaptureManagercameraManagerpublic BeepManager getBeepManager()
getBeepManager 在接口中 CaptureManagerbeepManagerpublic com.king.zxing.AmbientLightManager getAmbientLightManager()
AmbientLightManagergetAmbientLightManager 在接口中 CaptureManagerambientLightManagerpublic com.king.zxing.InactivityTimer getInactivityTimer()
InactivityTimergetInactivityTimer 在接口中 CaptureManagerinactivityTimer