mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-05-16 15:02:54 +00:00
Started working on ZXing
This commit is contained in:
parent
c0219fbc35
commit
3df18c0226
9 changed files with 89 additions and 12 deletions
|
@ -1,13 +1,26 @@
|
|||
package me.impy.aegis;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
Button btnScan;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
btnScan = (Button) findViewById(R.id.button);
|
||||
btnScan.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Intent scannerActivity = new Intent(getApplicationContext(), ScannerActivity.class);
|
||||
startActivity(scannerActivity);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
44
app/src/main/java/me/impy/aegis/ScannerActivity.java
Normal file
44
app/src/main/java/me/impy/aegis/ScannerActivity.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue