Reputation: 14621
I have an android project that I want to "clone" for a second similar project which only differs by one file: it's sqlite database (assets/mydata.sql).
I've turned the source project (reslib) into a library and added it to my clone project's properties (the source project shows up under "Library Projects" as reslib.jar)
Thing is, I'm not sure how to launch the main activity in the source project. The source project's main activity sets-up a TabHost. How do I launch into the source project's main activity from my clone project? I started pasting code into "cloneActivity.java" to fire up the TabHost but then wondered if there was a better way.
Upvotes: 0
Views: 767
Reputation: 2364
Doing this is pretty straight-forward. In the manifest for your dependent project, you need to specify the source project's activity as the one you want to launch.
Suppose your source project has package name com.example.source
, your dependent project has package name com.example.dependent
, and the main activity in your source project is MainActivity.java
.
Then in AndroidManifest.xml in your dependent project, you would have something like the following:
<application
android:icon="@drawable/logo" >
<activity
android:name="com.example.source.MainActivity" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- possibly lots more activities and other declarations -->
</application>
Important Notes: In the manifests for both your source project and the dependent project, you must make sure to list all activities, permissions, etc. If later on you add an activity to your source project, you'll need to remember to add it to the dependent project's manifest as well.
Also, you'll need to copy anything in the source project's assets directory to the dependent project—and don't forget to keep that in sync as well. (This is true as of June 2012, I've heard that some future version of the Android build tools will likely alleviate this headache.)
And finally, if you use Eclipse to create the projects, it will create a default layout main.xml
. Since resources in the dependent project override resources in the source project, make sure this doesn't trip you up.
Upvotes: 1