I have an Android project. Now I need to create a second edition of that project.
What will differ:
New edition of the Project should have different content in one of the Activities.
I was thinking about creating a library project and two new projects(project1
and project2
) which will use library project, but I don't really understand how to setup this.
Should I just convert the original project into library, then create two new projects and then what? How to make project1
use activity1
and project2
use activity2
in the same place?
EDIT
What I've set up so far:
MainProject, a library has MainActivity.java and ChildActivity.java
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mainproject">
<application>
<activity
android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ChildActivity">
</activity>
</application>
</manifest>
MainActivity.java
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, ChildActivity.class);
startActivity(intent);
}
});
}
}
StandAloneProject: it has only ChildActivity.java
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.standaloneproject">
<application>
<activity
android:name="com.example.mainproject.MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ChildActivity" >
</activity>
</application>
</manifest>
What I expect:
When I launch StandAloneProject and click button, I want ChildActivity from StandAloneProject(not from MainProject) to be launched.
What I get:
When I launch StandAloneProject, I see MainActivity from MainProject, click button and get:
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.standaloneproject/com.example.mainproject.ChildActivity}; have you declared this activity in your AndroidManifest.xml?