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

126
Views
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 answers
Answer question

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 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!