1 package org.average.nfcauthcr;
3 import android.app.Activity;
4 import android.app.AlertDialog;
5 import android.app.PendingIntent;
6 import android.content.DialogInterface;
7 import android.content.Intent;
8 import android.content.IntentFilter;
9 import android.nfc.NfcAdapter;
10 import android.nfc.Tag;
11 import android.nfc.TagLostException;
12 import android.nfc.tech.IsoDep;
13 import android.util.Log;
14 import android.widget.Toast;
16 import org.average.nfcauthcr.NfcCRdispatch;
18 public class TagEvent extends Activity {
20 private final String TAG = getClass().getName();
22 private NfcCRdispatch dispatch = new NfcCRdispatch((Activity)this);
25 protected void onResume() {
27 Log.v(TAG, "Starting the work");
29 new AlertDialog.Builder(this)
30 .setTitle(R.string.challenging)
31 .setMessage(R.string.swipe)
33 new DialogInterface.OnCancelListener() {
34 public void onCancel(DialogInterface dialog) {
41 Intent intent = getIntent();
42 setResult(RESULT_CANCELED);
43 byte[] challenge = intent.getByteArrayExtra("challenge");
44 dispatch.onResume(challenge);
48 protected void onPause() {
50 Log.v(TAG, "Finished the work");
55 public void onNewIntent(Intent newintent) {
56 Log.v(TAG, "NFC Intent arrived");
58 byte[] response = dispatch.onNewIntent(newintent);
59 if (response != null) {
60 Intent masterintent = getIntent();
61 masterintent.putExtra("response", response);
62 setResult(RESULT_OK, masterintent);