Back to project page barcodescanner.
The source code is released under:
Apache License
If you think the Android project barcodescanner listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package me.dm7.barcodescanner.zbar.sample; //w w w . j a v a2 s . c om import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.Toast; import me.dm7.barcodescanner.zbar.Result; import me.dm7.barcodescanner.zbar.ZBarScannerView; public class SimpleScannerFragment extends Fragment implements ZBarScannerView.ResultHandler { private ZBarScannerView mScannerView; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { mScannerView = new ZBarScannerView(getActivity()); return mScannerView; } @Override public void onResume() { super.onResume(); mScannerView.setResultHandler(this); mScannerView.startCamera(); } @Override public void handleResult(Result rawResult) { Toast.makeText(getActivity(), "Contents = " + rawResult.getContents() + ", Format = " + rawResult.getBarcodeFormat().getName(), Toast.LENGTH_SHORT).show(); mScannerView.startCamera(); } @Override public void onPause() { super.onPause(); mScannerView.stopCamera(); } }