为什么在安装我的应用程序时出现错误的快捷方式名称?

时间:2014-04-06 13:55:03

标签: android installation shortcut

我最近向Android市场发布了我的第一个应用程序,并注意到如果用户在其Play商店应用中将“添加图标到主屏幕”设置为true,则安装过程中创建的快捷方式名称错误。

取代在应用程序标签上指定的字符串或intent过滤器上的标签,它将获取活动的标签。

如果用户手动创建快捷方式,则命名正确。

以下是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>

我见过有关类似问题的其他问题,例如: How to set different label for launcher rather than activity title? 但我的问题只发生在上面指定,手动创建的快捷方式和启动器/程序菜单中的图标都有正确的名称。

我所有快捷方式的所需名称在:@ string / app_name中指定 而我不想要的是:@ string / categories

为什么会发生这种情况以及如何避免这种情况?

如果可能的话,我想避免将我的类别活动的标题更改为app_name的解决方案,然后以编程方式更改onCreate中的标题,因为我听说这导致app_name在显示前不久显示以编程方式设置要显示的标题。

EDIT1:我尝试在尽可能小的环境中重新创建问题,因此我创建了一个新的Android项目,并进行了必要的更改以说明问题,然后我将其发布在Google Play上作为“测试App Store快捷方式“。可以从https://play.google.com/store/apps/details?id=com.dosolves.testappstoreshortcutname或通过搜索我的名字“David Svedberg”下载它。如果您想重新创建此问题,请务必在Android设备上的Play商店应用中更改设置,以便在主屏幕上自动创建快捷方式。

最低应用程序完整显示:

<?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>

和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:我刚才注意到,如前所述,手动创建的快捷方式首先给出了正确的名称,但在重新启动设备后,他们会得到错误的名称。

2 个答案:

答案 0 :(得分:2)

我刚遇到同样的问题,最后将应用名称设置为启动器活动标签,然后使用setTitle设置实际的活动名称。如果您在setTitlesuper.onCreate之前致电setContentView,则活动名称前不会显示应用名称。我也认为这是一个hacky解决方法,并想知道为什么我无法在网络上找到更多有关此问题的信息。

答案 1 :(得分:0)

我刚遇到同样的问题,我发现Appname正在使用我导入的一个库Appname,因为我的应用程序没有在res / values- [language]中设置的语言,但是库有它,因此它显示了库appname。