Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New Android Project named after Main Activity instead of app name

I am creating new android projects in Eclipse Juno with the latest ADT plugin and im running into a problem with the name of the app. Whenever I run the app, it runs fine, but when I go to the app list, the name of the app isnt there. Instead I have a new app named MainActivity which is the name of the first activity in the app. The app_name string is set to the name of the app, but it still doesnt work. I figured out changing the title_activity_main to the name of the application fixed the problem with the wrong app name in the app drawer, but that seems like a backwoods kind of way to fix that. Anyone else experience that problem, or just hating the new ADT like me?

Manifest Code

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.bv.testapp"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="4"
    android:targetSdkVersion="15" />

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name">
    <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>
</application>

like image 886
Shaun Avatar asked Aug 23 '12 03:08

Shaun


People also ask

Can we change the name of main activity in Android?

Yes, you can change the name of MainActivity by, opening the directory of the java file in android studio, right-click on it and find refactor, then rename, put in the name you like then click on refactor.

Is new activity that is used in an Android app must be defined in?

Every activity that the android app uses must be declared in the AndroidManifest. xml file. and the main activity for the app must be declared in the manifest with a <intent-filter> that includes the MAIN action and LAUNCHER.


2 Answers

Recently i have this problem: can you please try with this:

<activity
    android:name=".MainActivity"
    android:label="@string/app_name" >

or remove android:label from activity

like image 129
Saifuddin Sarker Avatar answered Sep 21 '22 18:09

Saifuddin Sarker


I found the solution for you.. In the manifest file, you are able to set one label for the launcher icon, and another for the activity. The app name is set in the intent filter, like this:

<activity
    android:name=".Start"
    android:label="@string/activity_start" >
    <intent-filter android:label="@string/app_name" >
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

Cheers

//Nautious

like image 25
Anders Avatar answered Sep 20 '22 18:09

Anders