Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

127
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda