Change history for NFC
1. In AndroidManifest.xml
Add:
Change attributition of RequestCardActivity, change launchMode to SingleTask is mandatory:
2. Add res/xml/nfctechfilter.xml
3. In MainApp.java
import android.nfc.NfcAdapter;
import android.nfc.Tag;
import android.nfc.tech.IsoDep;
public IsoDep isoDep;
public NfcAdapter nfcAdapter;
public Tag nfcTag;
4. In RequestCardActivity.java
import android.app.PendingIntent;
import android.content.IntentFilter;
import android.nfc.NfcAdapter;
import android.nfc.tech.IsoDep;
import android.nfc.tech.NfcA;
private PendingIntent pendingIntent;
private void enableForegroundDispatch() {
// nfc
IntentFilter[] filters = new IntentFilter[]{new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED), new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED)};
String[][] techLists = new String[][]{new String[]{IsoDep.class.getName(), NfcA.class.getName()}};
appState.nfcAdapter.enableForegroundDispatch(this, pendingIntent, filters, techLists);
}
private void disableForegroundDispatch() {
appState.nfcAdapter.disableForegroundDispatch(this);
}
@Override
protected void onNewIntent(Intent intent) {
Log.i(TAG, "onNewIntent: " + intent.getAction());
super.onNewIntent(intent);
if (NfcAdapter.ACTION_TECH_DISCOVERED.equals(intent.getAction())){
// NFC event,
appState.nfcTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG);
appState.isoDep = IsoDep.get(appState.nfcTag);
if(appState.isoDep != null){
try{
appState.isoDep.connect();
}catch(IOException e){
Log.d(TAG, "IsoDep.coonect get exception: " + e.getMessage());
}
if(appState.isoDep != null && appState.isoDep.isConnected()){
setIsoDep(appState.isoDep);
// Contactless card tapped
Message msg = new Message();
appState.cardType = CARD_CONTACTLESS;
msg.what = CARD_TAPED_NOTIFIER;
mHandler.sendMessage(msg);
}
}
}
}
// In onCreate Function, Add:
if(appState.wizarType == WizarTypeUtil.WIZARTYPE.WIZARPOS_Q3PDA)
{
appState.nfcAdapter = NfcAdapter.getDefaultAdapter(this);
if(appState.nfcAdapter == null || appState.nfcAdapter.isEnabled() == false)
{
txtError.setText("Get NFC Adapter Error");
return;
}
Intent intent = new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
pendingIntent = PendingIntent.getActivity(
this, 0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_MUTABLE
);
}
5. Please search "WIZARTYPE.WIZARPOS_Q3PDA" to find others fractional changes.