Created
July 29, 2017 11:15
-
-
Save pjwelcome/401ee89a50df2b428a023dcc24f70be7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T>enableNFCInForeground(nfcAdapter: NfcAdapter, activity: Activity, classType : Class<T>) { | |
val pendingIntent = PendingIntent.getActivity(activity, 0, | |
Intent(activity,classType).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0) | |
val nfcIntentFilter = IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED) | |
val filters = arrayOf(nfcIntentFilter) | |
val TechLists = arrayOf(arrayOf(Ndef::class.java.name), arrayOf(NdefFormatable::class.java.name)) | |
nfcAdapter.enableForegroundDispatch(activity, pendingIntent, filters, TechLists) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment