我已成功将 zxing core.jar
库集成到android Marshmallow 下面,但在将其整合到Marshmallow上方时,它会出现以下错误:
android.content.ActivityNotFoundException: NO activity found to handle
intent{act=com.google.zxing.client.android.SCAN}
提前致谢。
答案 0 :(得分:0)
@ Kevin Robatel 我的清单
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
以下代码执行onClick按钮
try {
Intent intent = new Intent("com.google.zxing.client.android.SCAN");
//intent.putExtra("SCAN_MODE", "PRODUCT_MODE");
startActivityForResult(intent, BARCODE_CAPTURE_ACTIVITY);
} catch (ActivityNotFoundException anfe) {
Toast.makeText(mContext, "Scanner Not Found "+anfe.toString() , Toast.LENGTH_LONG).show();
}
答案 1 :(得分:0)
我认为问题可能在于Camera的运行时权限。尝试通过代码或手动访问您的应用
答案 2 :(得分:0)
您应该在Manifest文件中编辑代码:
<activity
android:name="com.google.zxing.client.android.CaptureActivity"
android:configChanges="orientation|keyboardHidden"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
不要忘记添加权限:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA"/>