0

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.

Calvin Ng
  • 33
  • 4

2 Answers2

0

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!

  • You mean I should consider first way instead of the second way ? If this is the case, Should I preserve one mainActivity class only and rename other 2 mainActivity class of other 2 project ? or I just put everything inside mainActivity class from other 2 projects into the mainActivity class of the first project ? – Calvin Ng May 25 '15 at 15:42
  • Yes the first way it's the good solution, the thing is if you need code of 3 projects in 1 app then you needs to put all code in one project, but copy code is a bad way, the good way is import classes from other projects and rename this classes are imported. You need to see this as one project - one application, different projects - different applications. Good luck! – Merlí Escarpenter Pérez May 25 '15 at 15:49
-1

If you add a custom action to your activity:

<activity
   android:name=".MainActivity"
   android:label="@string/app_name" >
   <intent-filter>
       <action android:name="android.intent.action.MAIN" />
       <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
   <intent-filter>
       <action android:name="com.example.action.MYACTION" />
       <category android:name="android.intent.category.DEFAULT"/>
   </intent-filter>
</activity>

You can invoke it via implicit intent as long as the app already installed on the device:

Intent i = new Intent("com.example.action.MYACTION");
startActivity(i);
tachyonflux
  • 20,103
  • 7
  • 48
  • 67