Hi I am new to android and I have created 2 projects.
Now I want to call an activity in the second project from the first project upon a button click.
The 1
in the map project's AndroidManifest file add your custom intent filter
<!-- add custom action -->
<activity android:name="MapActivity"
android:label="@string/mapLabel"
>
<intent-filter>
<action android:name="com.example.map.show" />
</intent-filter>
</activity>
from the login button call this activity like this:
Intent intent = new Intent("com.example.map.show"); startActivity(intent);
You should be using one project for each application. If you want to split up your login from the rest of your application you could use different packages. Unless I am misunderstanding what you mean by "project"?
According to Android you can handle this by making the project Library and then Define it in the manifest file and call it in what ever manner you want
for an explanation i did this as per my requirement
the activity you want to call on Button click Define it in the Manifest with its full package name and then when you call it on button click the activity of the new project will trigger
the sample to do this is following
in the manifest
file of your 1st project define some thing like this
<activity
android:name="packagefull.activityname"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>
in the package name define the full path of the the activity you want to call and after the package name give the name of the activity hope this will work for you as this worked perfect for me
Use this:
Intent i = new Intent(Intent.ACTION_MAIN);
i.setComponent(new ComponentName("app package name", "app launch activity's classname"));
i.addCategory(Intent.CATEGORY_LAUNCHER);
startActivity(i);
This is really not a good way for developing any application. But still if you want to achieve this , you will have to declare an Intent Filter for the target activity in that application's Manifest file and use it as implicit intent from your login activity.
Inside project A's Manifest:
<activity android:name="com.example.android.TargetActivity">
<intent-filter>
<action android:name="com.someone.wants.to.call.me"></action>
</intent-filter>
</activity>
Inside project B's Activity:
Intent intent = new Intent("com.someone.wants.to.call.me");
startActivity(intent);