Zxing条形码
程序员文章站
2024-03-24 12:12:52
...
- 介绍
- EAN-13
- 嵌入安卓
<activity
android:configChanges="orientation|keyboardHidden"
android:name="org.suren.market.zxing.activity.CaptureActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden" >
</activity>
[/codesyntax] 要注意上面的Activity的路径。 然后就是调用条形码扫描的代码了: Intent openCameraIntent = new Intent(BillActivity.this, CaptureActivity.class); startActivityForResult(openCameraIntent, 0); 最后是获取扫描结果的代码: [codesyntax lang="java"]
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
Bundle bundle = data.getExtras();
String scanResult = bundle.getString("result");
System.out.println(scanResult);
}
}
[/codesyntax] 是不是感觉很简单啊。
- 参考
转载于:https://my.oschina.net/surenpi/blog/816963