Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

128
Vistas
How to call main app module function in library module Android Studio

I'm working on an existing project and would like to call refresh function in main app module from the library module. So when the library module verifyCode is complete it will call the main app's refresh function to refresh the view again.

build.gradle(:app)
    
dependencies {
    .
    .
    .
    implementation project(path: ':dependency')
}
    

main app module

open class BaseActivity : AppCompatActivity() {
    lateinit var pref: PreferenceManager
    lateinit var repository: BasicRepository

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        pref = PreferenceManager(this)
        setupContentWindow()
    }

    override fun onResume() {
        super.onResume()

    if (pref.checkCredential()) {
        val intent = PinCodeActivity.intent(this, true, pref.token())
        startActivity(intent)
    }
    refresh()
}

private fun refresh() {
    //refresh user data
}

library module

private void checkCode(String pin, String token) {
    APIManager.getInstance().verifyCode(token, pin, new Callback<String>() {
        @Override
        public void onResponse(Call<String> call, Response<String> response) {
            String responseUser = response.body();
            if (response.code() == 200) {
                if (responseUser == "true") {
                    setResult(RESULT_OK);
                    finish();
                    //call main app refresh function after the endpoint return 200
                } else {
                    //do something
                }
            } else {
                  //do something
            }
        }

        @Override
        public void onFailure(Call<String> call, Throwable t) {
            //do something
        }
    });
} 
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can't pass data from build gradle files. You need to use intents/broadcasts to send data between modules.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda