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

221
Views
El Oyente no funciona... Parece que el Oyente es 0

Hola chicos, tengo esto como MainActivity:

 public class LoginActivity extends AppCompatActivity { public interface LoginListener { public void onLoginSuccess(); } public void onLoginSuccess() { //logged in and do a few other things } }

Y esa es mi segunda Actividad desde donde quiero llamar al método onLoginSuccess() en mi MainActivity, como pueden ver, estoy haciendo esto con un Oyente...

 public class FingerprintHandler extends FingerprintManager.AuthenticationCallback { private LoginActivity.LoginListener mListener; public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) { if (mListener != null) { mListener.onLoginSuccess(); } else{ Toast.makeText((Activity)context, "Listener is 0", Toast.LENGTH_LONG).show(); } } }

MI problema es que cada vez que lo pruebo recibo: "El oyente es 0" de mi Toast... Entonces, ¿qué pasa?

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

Verifique el código a continuación para la autenticación de huellas digitales en Android

https://gist.github.com/Evin1-/6aca8421903acca0e927eaefd85bd617

over 4 years ago · Santiago Trujillo Report

0

Extensión de mi comentario anterior:

Debe registrar mListener alguna manera. Un patrón para hacer esto es:

 public class MyHandler { private LoginListener mListener; public MyHandler(LoginListener listener) { mListener = listener; } // ... etc... }

Donde LoginListener es:

 public interface LoginListener { public void onLoginSuccess(); }

Y tu actividad tiene:

 public MyActivity implements LoginListener { // instantiate the handler somewhere, with a reference // to "this". "this" refers to the LoginListener interface // which is implemented. @Override public void onCreate(Bundle b) { mHandler = new MyHandler(this); } @Override public void onLoginSuccess() { Log.i(TAG, "Kewel beanZ"); } }

O bien, puede definir LoginListener como una interfaz dentro de la actividad si lo desea, y crear una instancia como:

 public LoginListener mListener = new LoginListener() { @Override public void onLoginSuccess() { Log.i(TAG, "Sweet sweet baby beanz"); } };

Y en lugar de usar this , use mListener cuando cree MyHandler .

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!