mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-21 14:29:13 +00:00
44 lines
1.4 KiB
Java
44 lines
1.4 KiB
Java
|
package me.impy.aegis;
|
||
|
|
||
|
import android.app.Activity;
|
||
|
import android.support.v7.app.AppCompatActivity;
|
||
|
import android.os.Bundle;
|
||
|
import android.util.Log;
|
||
|
|
||
|
import com.google.zxing.Result;
|
||
|
|
||
|
import me.dm7.barcodescanner.zxing.ZXingScannerView;
|
||
|
|
||
|
public class ScannerActivity extends Activity implements ZXingScannerView.ResultHandler {
|
||
|
private ZXingScannerView mScannerView;
|
||
|
|
||
|
@Override
|
||
|
public void onCreate(Bundle state) {
|
||
|
super.onCreate(state);
|
||
|
mScannerView = new ZXingScannerView(this); // Programmatically initialize the scanner view
|
||
|
setContentView(mScannerView); // Set the scanner view as the content view
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void onResume() {
|
||
|
super.onResume();
|
||
|
mScannerView.setResultHandler(this); // Register ourselves as a handler for scan results.
|
||
|
mScannerView.startCamera(); // Start camera on resume
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void onPause() {
|
||
|
super.onPause();
|
||
|
mScannerView.stopCamera(); // Stop camera on pause
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void handleResult(Result rawResult) {
|
||
|
// Do something with the result here
|
||
|
Log.v("Aegis ", rawResult.getText()); // Prints scan results
|
||
|
Log.v("Aegis ", rawResult.getBarcodeFormat().toString()); // Prints the scan format (qrcode, pdf417 etc.)
|
||
|
|
||
|
// If you would like to resume scanning, call this method below:
|
||
|
mScannerView.resumeCameraPreview(this);
|
||
|
}
|
||
|
}
|