I've added a reference to a new module and try to open an Activity
from it.
It throws
an Exception
that says:
android.content.ActivityNotFoundException: Unable to find explicit activity class{
com.giljulio.imagepicker.ui/com.giljulio.imagepicker.ui.ImagePickerActivity };
have you declared this activity in your AndroidManifest.xml?
Do I need to add anything else beside reference the new module
?
MainActivity can call any activity from library module. But you can't call MainActivity from library module. You can back to MainActivity via onBackPressed (). RK88 likes this. Thanks for your reply. Appreciate. Yes. I am talking about 2 Phone/Tablet Modules currently.
Download project, open in Android Studio 3.1, Start one module "app". Start another module aad_20180426a. Now both modules installed into device or emulator. Then click on FAB on any of module. You will switch between them back and force. 2. One module app and android library module
If you run the app and tap the button on the first activity, the second activity starts but is empty. This is because the second activity uses the empty layout provided by the template. Figure 1.
App module is master, library module is slave. MainActivity can call any activity from library module. But you can't call MainActivity from library module. You can back to MainActivity via onBackPressed (). RK88 likes this. Thanks for your reply.
You have to define in gradle dependencies(in module where you want to call another module activity):
dependencies{
...
compile project(':yourModuleName')
...
}
After adding this sync the gradle and now can you use the activity in the module.
User like this. This will help you
Intent intent = null;
try {
intent = new Intent(this,
Class.forName("ir.test.testlibary1.HelloWorldActivity"));
startActivity(intent);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With