Question

I recently published my first app to the android marketplace and noticed that if the user has the setting "Add icon to home screen" set to true in their Play Store app, the shortcut that gets created during installation has the wrong name.

Instead of the string specified on the application label or the label on the intent filter it gets the label of the activity.

If the user manually creates a shortcut, the naming is correct.

Here's an excerpt from my AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.dosolves.gym"
    android:versionCode="2"
    android:versionName="1.1" >

   ...

    <application
        android:name="com.dosolves.gym.app.GymApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="com.dosolves.gym.app.category.gui.CategoriesActivity"
            android:label="@string/categories" >
            <intent-filter android:label="@string/app_name" >
                <action android:name="android.intent.action.MAIN" />

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

   ...

    </application>

</manifest>

I've seen other questions regarding similar problems e.g.: How to set different label for launcher rather than activity title? But my problem only occurs as specified above, both manually created shortcuts and the icon in the launcher/program menu have the correct name.

The desired name for all my shortcuts is specified in: @string/app_name And the one I don't want is: @string/categories

Any ideas why this happens and how I can avoid it?

If at all possible I would like to avoid the solution to change the title of my categories activity to app_name and then programmatically change the title in onCreate as I've heard that this causes the app_name to be displayed a short while before the programmatically set title to be displayed.

EDIT1: I tried to recreate the issue in the smallest possible environment so I created a new android project and made the necessary changes that would illustrate the issue and then I published it on Google Play as "Test App Store Shortcut". It's can be downloaded from: https://play.google.com/store/apps/details?id=com.dosolves.testappstoreshortcutname or by searching my name "David Svedberg". If you want to recreate the issue, be sure to change your settings in the play store app on your android device to automatically create shortcut on home-screen.

The minimum apps manifest in it's entirety:

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

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/right_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.dosolves.testappstoreshortcutname.MainActivity"
            android:label="@string/wrong_name" >
            <intent-filter android:label="@string/right_name">
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

and the string.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <string name="right_name">Right Name</string>
    <string name="action_settings">Settings</string>
    <string name="hello_world">Hello world!</string>
    <string name="wrong_name">Wrong Name</string>

</resources>

EDIT2: I just noticed that shortcuts created manually are, as said before, given the correct name at first but after a restart of the device they get the wrong name instead.

Was it helpful?

Solution

I just encountered the same problem and ended up with setting the app name as the launcher activity label and then using setTitle to set the actual activity name. The app name will not be shown a short while before the activity name if you call setTitle before super.onCreate and setContentView. I also think that this is a hacky workaround and wonder why I cannot find more about this issue on the web.

OTHER TIPS

I just encounter the same problem, I found that the Appname is using one of my imported library Appname, because my app without a language set in the res/values-[language] but the library has it, thus it displays the library appname.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top