user1174834
user1174834

Reputation: 239

Simple AndroidManifest.xml Questions

First, do I need to create a new <activity> in my AndroidManifest.xml for each new java class?

Second, here is my AndoidManifest.xml

 <?xml version="1.0" encoding="utf-8"?>
    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.Alan.Gym_Rat"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".GymRatActivity"
            android:label="@string/app_name" 
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity 
            android:name="mainmenu"
            android:label="@string/app_name" 
            android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

Does that look right? Because When I run the emulator, it shows two icons, so im not sure if I set things up right. The only addition I have made really is to get rid of the title bar.

Third and last, how do you specify the name of the app icon so its not the default name of the AVD?

Upvotes: 0

Views: 2496

Answers (3)

aerobrain
aerobrain

Reputation: 623

I would like to comment above but my reputation still not enough.

The name that appears in the icon label is determined by app_name which is defined in strings.xml.

Upvotes: 1

Harneet Kaur
Harneet Kaur

Reputation: 4497

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.Alan.Gym_Rat"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name" >
    <activity
        android:name=".GymRatActivity"
        android:label="@string/app_name" 
        android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity 
        android:name=".MainMenu"
        android:screenOrientation="portrait" /*In case you want to set orientation of  
       screen.In similar you can use other properties according to requirement*/  
    >
    </activity>
     </application>

     </manifest>

Upvotes: 0

EboMike
EboMike

Reputation: 77722

Yes, you do have to create a new activity entry in the manifest file for each activity. The reason why you see two icons is because you marked them both with android.intent.category.LAUNCHER. That should be reserved for things you want to show up in the launcher.

Likewise, the MAIN action should only be used for the main entry point of your app.

By the way, what are the class names of your activities? I'll assume it's not mainmenu, so you need to adjust the name to the actual class name. Also, you should prepend a dot (so if the class name is MainMenu, write .MainMenu).

And the name should be what you specify in the label.

Upvotes: 2

Related Questions