Java Code Examples for android.nfc.NfcAdapter#ACTION_TECH_DISCOVERED
The following examples show how to use
android.nfc.NfcAdapter#ACTION_TECH_DISCOVERED .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java From flutter-nfc-app with MIT License | 6 votes |
@TargetApi(Build.VERSION_CODES.KITKAT) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); GeneratedPluginRegistrant.registerWith(this); Log.i("", "onCreate"); mAdapter = NfcAdapter.getDefaultAdapter(this); if (mAdapter == null) { Log.i("", "mAdapter null"); } mPendingIntent = PendingIntent.getActivity( this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); mFilters = new IntentFilter[]{new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED)}; mTechLists = new String[][]{new String[]{IsoDep.class.getName()}}; new MethodChannel(getFlutterView(), CHANNEL).setMethodCallHandler( new MethodChannel.MethodCallHandler() { @Override public void onMethodCall(MethodCall call, MethodChannel.Result result) { if (call.method.equals("getPlatformVersion")) { result.success("Android ${android.os.Build.VERSION.RELEASE}"); } else if (call.method.equals("getCardUID")) { result.success(getCardUID()); } else if (call.method.equals("getVersion")) { String commands = call.argument("commands"); result.success(getVersion(commands)); } else { result.notImplemented(); } } }); }
Example 2
Source File: WifiNetworkActivity.java From WiFiKeyShare with GNU General Public License v3.0 | 6 votes |
private void setupForegroundDispatch() { /* initialize the PendingIntent to start for the dispatch */ nfcPendingIntent = PendingIntent.getActivity( this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); /* initialize the IntentFilters to override dispatching for */ nfcIntentFilters = new IntentFilter[3]; nfcIntentFilters[0] = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); nfcIntentFilters[0].addCategory(Intent.CATEGORY_DEFAULT); nfcIntentFilters[1] = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); nfcIntentFilters[1].addCategory(Intent.CATEGORY_DEFAULT); nfcIntentFilters[2] = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); nfcIntentFilters[2].addCategory(Intent.CATEGORY_DEFAULT); try { nfcIntentFilters[0].addDataType("*/*"); // Handle all MIME based dispatches. } catch (IntentFilter.MalformedMimeTypeException e) { Log.e(TAG, "setupForegroundDispatch: " + e.getMessage()); } /* Initialize the tech lists used to perform matching for dispatching of the * ACTION_TECH_DISCOVERED intent */ nfcTechLists = new String[][] {}; }
Example 3
Source File: MainActivity.java From bankomatinfos with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // find view elements _viewProgressStatus = findViewById(R.id.read_card_status); _viewNfcLogo = findViewById(R.id.imageViewNfcLogo); _viewTextViewShowCard = findViewById(R.id.textViewYourCardPlease); // NFC stuff _pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); _filters = new IntentFilter[] { new IntentFilter( NfcAdapter.ACTION_TECH_DISCOVERED) }; _techLists = new String[][] { { "android.nfc.tech.NfcA" } }; _nfcAdapter = NfcAdapter.getDefaultAdapter(this); // create last changes dialog if needed displayWhatsNew(); }
Example 4
Source File: NfcDetectorActivity.java From effective_android_sample with Apache License 2.0 | 6 votes |
/** * * Initialize Nfc fields * */ protected void initializeNfc() { nfcAdapter = NfcAdapter.getDefaultAdapter(this); nfcPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, this.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); IntentFilter techDetected = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); writeTagFilters = new IntentFilter[] {ndefDetected, tagDetected, techDetected}; nfcStateChangeBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final int state = intent.getIntExtra(EXTRA_ADAPTER_STATE, -1); if(state == STATE_OFF || state == STATE_ON) { runOnUiThread(new Runnable() { public void run() { if(state == STATE_ON) { if(detecting) { enableForeground(); } } detectNfcStateChanges(); } }); } } }; }
Example 5
Source File: MainActivity.java From android-nfc-tag-read-write with MIT License | 5 votes |
@Override protected void onResume() { super.onResume(); IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); IntentFilter techDetected = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); IntentFilter[] nfcIntentFilter = new IntentFilter[]{techDetected,tagDetected,ndefDetected}; PendingIntent pendingIntent = PendingIntent.getActivity( this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); if(mNfcAdapter!= null) mNfcAdapter.enableForegroundDispatch(this, pendingIntent, nfcIntentFilter, null); }
Example 6
Source File: TagDispatcher.java From GreenBits with GNU General Public License v3.0 | 5 votes |
private void enableForegroundDispatch(NfcAdapter adapter, Intent intent) { if(adapter.isEnabled()) { PendingIntent tagIntent = PendingIntent.getActivity(activity, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); IntentFilter tag = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); adapter.enableForegroundDispatch(activity, tagIntent, new IntentFilter[]{tag}, new String[][]{new String[]{IsoDep.class.getName()}}); } }
Example 7
Source File: TagDispatcher.java From nordpol with MIT License | 5 votes |
private void enableForegroundDispatch(NfcAdapter adapter, Intent intent) { if(adapter.isEnabled()) { PendingIntent tagIntent = PendingIntent.getActivity(activity, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); IntentFilter tag = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); adapter.enableForegroundDispatch(activity, tagIntent, new IntentFilter[]{tag}, new String[][]{new String[]{IsoDep.class.getName()}}); } }
Example 8
Source File: NfcDetectorActivity.java From external-nfc-api with Apache License 2.0 | 5 votes |
/** * * Initialize Nfc fields * */ protected void initializeNfc() { nfcAdapter = NfcAdapter.getDefaultAdapter(this); nfcPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, this.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); IntentFilter techDetected = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); IntentFilter tagLost = new IntentFilter(ACTION_TAG_LEFT_FIELD); writeTagFilters = new IntentFilter[] {ndefDetected, tagDetected, techDetected, tagLost}; nfcStateChangeBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { final int state = intent.getIntExtra(EXTRA_ADAPTER_STATE, -1); if(state == STATE_OFF || state == STATE_ON) { runOnUiThread(new Runnable() { public void run() { if(state == STATE_ON) { if(detecting) { enableForeground(); } } detectNfcStateChanges(); } }); } } }; }
Example 9
Source File: TagDispatcher.java From WalletCordova with GNU Lesser General Public License v2.1 | 5 votes |
private void enableForegroundDispatch(NfcAdapter adapter, Intent intent) { if(adapter.isEnabled()) { PendingIntent tagIntent = PendingIntent.getActivity(activity, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT); IntentFilter tag = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); adapter.enableForegroundDispatch(activity, tagIntent, new IntentFilter[]{tag}, new String[][]{new String[]{IsoDep.class.getName()}}); } }
Example 10
Source File: NfcUtil.java From zap-android with MIT License | 4 votes |
public static IntentFilter[] IntentFilters() { IntentFilter tagDetected = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); IntentFilter techDetected = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); return new IntentFilter[]{techDetected, tagDetected, ndefDetected}; }