Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

277
Views
¿Cómo detectar el evento de eliminación de etiquetas NFC?

Desarrollo una aplicación de Android para leer/escribir en tarjetas inteligentes sin contacto a través de NFC. Necesito detectar cuando la tarjeta está fuera de rango. traté de usar

 NFCAdapter.OnTagRemovedListener{ card_connected2.visibility = View.VISIBLE card_connectedgreen.visibility = View.GONE Toast.makeText(this@InquiryActivity, "card is disconnected", Toast.LENGTH_LONG).show() }

pero esto parece incorrecto y no funciona. También leí sobre NfcAdapter.ignore() , pero no puedo encontrar ningún ejemplo sobre cómo usarlo. ¿Cómo puedo hacer que funcione la devolución de llamada anterior?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

La interfaz OnTagRemovedListener se usa para especificar la devolución de llamada para el método NfcAdapter.ignore() . En consecuencia, debe llamar a ignore() con la devolución de llamada deseada. Por ejemplo, si desea ejecutar el código anterior, con un tiempo de espera de rebote de 1000 ms, podría usar algo como esto:

 // nfcAdapter: your instance of the NfcAdapter // tag: the tag handle that you obtained from the NFC intent or the onTagDetected() callback nfcAdapter.ignore(tag, 1000, NfcAdapter.OnTagRemovedListener { card_connected2.visibility = View.VISIBLE card_connectedgreen.visibility = View.GONE Toast.makeText(this@InquiryActivity, "card is disconnected", Toast.LENGTH_LONG).show() }, Handler(Looper.getMainLooper()))

Tenga en cuenta que nfcAdapter y la tag deben definirse en consecuencia. La función de devolución de llamada se invocará en el subproceso principal (IU).

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!