我目前正在开发一种扫描仪,可以读取一张图像中的多个QR码.我设法读取图像中的QR码,但它给了我不一致的结果.假设图像中有4个QR码,有时我可以读取2个,有时3个或仅1个.与原始扫描仪(ZXing扫描仪)不同,它可以快速解码.在我的情况下,我必须确保有足够的光线,图像不会模糊解码.
我正在使用它QRCodeMultiReader来解码图像.目前正在使用ZXingLibrary来创建应用程序.
以下是我的代码片段:
public void onPictureTaken(byte[] data, Camera camera) {
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inMutable = true;
Bitmap bitmap = BitmapFactory
.decodeByteArray(data, 0, data.length, opt);
Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>();
hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
LuminanceSource source = new RGBLuminanceSource(bitmap);
QRCodeMultiReader multiReader = new QRCodeMultiReader();
Result[] results = multiReader.decodeMultiple(new BinaryBitmap(
new HybridBinarizer(source)), hints);
}
Run Code Online (Sandbox Code Playgroud) 我想以编程方式获取主屏幕启动器中所有已安装快捷方式的列表.我在网上找到了很多片段,但没有一个提供正确的输出
对于此片段:
Intent shortcutsIntent = new Intent(Intent.ACTION_CREATE_SHORTCUT);
ArrayList<Intent> intentList = new ArrayList<Intent>();
Intent intent=null;
String launchers="";
final PackageManager packageManager=getPackageManager();
for(final ResolveInfo resolveInfo:packageManager.queryIntentActivities(shortcutsIntent, 0)) {
launchers=launchers+"\n"+resolveInfo.activityInfo.packageName;
intent=packageManager
.getLaunchIntentForPackage(resolveInfo.activityInfo.packageName);
intentList.add(intent);
}
Run Code Online (Sandbox Code Playgroud)
这只提供联系人,浏览器等预设快捷方式.不完全是在主屏幕上找到的.
而这个片段:
PackageManager pm = getPackageManager();
Intent i = new Intent("android.intent.action.MAIN");
i.addCategory("android.intent.category.HOME");
List<ResolveInfo> lst = pm.queryIntentActivities(i, 0);
if (lst != null) {
for (ResolveInfo resolveInfo : lst) {
}
}
}
Run Code Online (Sandbox Code Playgroud)
仅提供com.android.launcher的默认启动器.

我想创建类似上面的东西,这三个盒子,就像一个相机预览.关于该怎么做的任何想法或概念?
我尝试获取相机的实例并将其放置到三个camerapreview对象,但我收到一条错误消息,我想,这是不允许的.这是我的代码:
private CameraPreview mPreview;
private CameraPreview mPreview2;
private CameraPreview mPreview3;
private FrameLayout preview;
private FrameLayout preview2;
private FrameLayout preview3;
mCamera=getCameraInstance();
mCamera2=getCameraInstance();
mCamera3=getCameraInstance();
mPreview=new CameraPreview(getApplicationContext(), mCamera);
mPreview2=new CameraPreview(getApplicationContext(), mCamera2);
mPreview3=new CameraPreview(getApplicationContext(), mCamera3);
preview=(FrameLayout)findViewById(R.id.camSetA_qr1);
preview.addView(mPreview);
preview2=(FrameLayout)findViewById(R.id.camSetA_qr1);
preview2.addView(mPreview2);
preview3=(FrameLayout)findViewById(R.id.camSetA_qr1);
preview3.addView(mPreview3);
Run Code Online (Sandbox Code Playgroud)
和我的getinstance代码
public static Camera getCameraInstance() {
Camera c = null;
try {
c = Camera.open();
} catch (Exception e) {
}
return c;
}
Run Code Online (Sandbox Code Playgroud)