January 2013
Intermediate to advanced
408 pages
9h 23m
English
Unless you are writing a Hello World application, chances are good that your application contains several activities that you need to connect in order to form a cohesive application. This recipe shows you the various ways to link to another activity in your Android application.
Suppose you have two activities in your application. The following AndroidManifest.xml file shows the two activities classes, MainActivity and Activity2:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.learn2develop.linking"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Activity2"
android:label="@string/app_name" >
<intent-filter>
<action android:name="net.learn2develop.Activity2" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
Assuming you are currently in the MainActivity ...
Read now
Unlock full access