Search code examples
javaandroidbuttononclickmain-activity

Is it possible to call the mainActivity class of another project ?


I have 3 android projects, which they have different functions. Each project has its own mainActivity class. Now I want to merge the 3 projects into one. I can think of 2 ways to do it.

First way: open one of the 3 projects, then create new java class and xml files and copy all java class and xml content from other 2 projects. However, each project has its own mainActivity class. I don't know whether I should preserve one mainActivity class only and rename other 2 mainActivity class of other 2 projects. It seems that it is easy to encounter lots of bugs and messy.

Second way: use 3 buttons. onclick first button then the mainActivity class of project 1 will run. onclick second button then the mainActivity class of project 2 will run. onclick third button then the mainActivity class of project 3 will run. However, I don't know whether it is possible to do so. If yes, How can I do so ? I know how to onclick on a button to go to a new activity but is that the same to apply to onclick going to other project's mainActivity ?

I prefer the second method, if it is possible to do so. Could anyone help ? Please advise , thanks.


Solution

  • This think it's impossible, you need to import all functions in 1 project... You can't open other project with one button, you need to import classes and activities in your global project that you needs or create a new classes, but you can't call other projects. Good luck!