Zxing 1.7 和 Android API 15 - 扫描仪导致摩托罗拉设备上的应用程序崩溃
我有 Zxing 1.7 和 Android api 15。通过 Intent 集成扫描仪并添加 CaptureActivity,以便应用程序不会询问要使用哪个相机。创建 core.jar 并将其添加到 Android 项目 lib 中,并将 Zxing Android 作为库项目添加到我的项目中构建路径。 当我单击应用程序的“san”选项卡时,扫描仪无法工作并且应用程序第一次崩溃,但下次当我重新登录我的应用程序时,它可以使用相同的功能并且可以扫描条形码。 当应用程序第一次崩溃时,它会为 CaptureActivity 提供 ClassNot Found 异常。我已遵循所有要求的步骤,并在 Manifst.xml 文件中添加了 CaptureActivity。 请提供建议,因为我已经尝试了很多替代方案。 Zxing 是否仅适用于现已过时且其替代品为 10 的 Android API9?下面是我的 ScanActivity 的代码
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//Scan code
Intent intent= new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
//To aviod the complete action using dialog box
intent.setClassName(this, "com.google.zxing.client.android.CaptureActivity");
startActivityForResult( intent, 0 );
//getApplicationContext().startActivity( intent );
//View scanView = ((ActivityGroup) context).getLocalActivityManager().startActivity(id, newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
/*
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage( "com.google.zxing.client.android.SCAN" );
i.addCategory( Intent.CATEGORY_LAUNCHER );
startActivityForResult( i, 0);
*/
}
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
System.out.println("ScanRewardCodeActivity OnActivityResult Method");
if(requestCode == 0)
{
//Stop QR Code Reader intent
finishActivity( 0 );
TabActivity tabActivity = (TabActivity)getParent();
TabHost tabHost = tabActivity.getTabHost();
if(resultCode == RESULT_OK){
System.out.println("Done");
}
}
}
I have Zxing 1.7 and Android api 15. Integrated the scanner through Intent and added CaptureActivity so that application does not ask for which camera to use.Created core.jar and added it in Android project lib and added Zxing Android as library project to my project build path.
The scanner does not work and application crashes first time when i click on "san" tab of my app but next time the same functionality it works when i login back in my app and barcode can be scanned.
When the application crashes for first time it give ClassNot Found exception for CaptureActivity . I have followed all the requires steps and also added CaptureActivity in the Manifst.xml file.
Please advice as i have tried lots of alternatives. Does Zxing works only with Android API9 that is made obsolete now and its replacement is 10? Below is code for my ScanActivity
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//Scan code
Intent intent= new Intent("com.google.zxing.client.android.SCAN");
intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
//To aviod the complete action using dialog box
intent.setClassName(this, "com.google.zxing.client.android.CaptureActivity");
startActivityForResult( intent, 0 );
//getApplicationContext().startActivity( intent );
//View scanView = ((ActivityGroup) context).getLocalActivityManager().startActivity(id, newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
/*
Intent i = new Intent(Intent.ACTION_MAIN);
PackageManager manager = getPackageManager();
i = manager.getLaunchIntentForPackage( "com.google.zxing.client.android.SCAN" );
i.addCategory( Intent.CATEGORY_LAUNCHER );
startActivityForResult( i, 0);
*/
}
public void onActivityResult(int requestCode, int resultCode, Intent intent)
{
System.out.println("ScanRewardCodeActivity OnActivityResult Method");
if(requestCode == 0)
{
//Stop QR Code Reader intent
finishActivity( 0 );
TabActivity tabActivity = (TabActivity)getParent();
TabHost tabHost = tabActivity.getTabHost();
if(resultCode == RESULT_OK){
System.out.println("Done");
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里存在很多问题。
core/
或android/
代码。确保从项目中删除所有这些代码,因为我认为它们会干扰并导致崩溃。AndroidManifest.xml
android-integration/
中给出的代码,因为它确实有效There are a number of problems here.
core/
orandroid/
code. Make sure to remove all of this code from your project as I think it is interfering and causing the crash.AndroidManifest.xml
android-integration/
as it definitely works