【问题标题】:Why do I get the wrong shortcut name during installation of my app?为什么我在安装我的应用程序时得到错误的快捷方式名称?
【发布时间】:2014-04-06 13:55:02
【问题描述】:

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

获取活动的标签,而不是应用程序标签上指定的字符串或意图过滤器上的标签。

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

这是我的 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:我刚刚注意到手动创建的快捷方式,如前所述,一开始是正确的名称,但在重新启动设备后,它们会得到错误的名称。

【问题讨论】:

  • 我向 android 问题跟踪器提交了一份问题报告:code.google.com/p/android/issues/detail?id=68325,我将继续实施使用应用程序名称标记我的启动器活动的解决方法,然后在 onCreate 中更改标题,丑陋,但似乎没有其他人对此有任何问题,所以我猜这就是要走的路。

标签: android installation shortcut


【解决方案1】:

我刚刚遇到同样的问题,最终将应用名称设置为启动器活动标签,然后使用setTitle 设置实际活动名称。如果您在super.onCreatesetContentView 之前调用setTitle,应用程序名称将不会在活动名称之前显示一小段时间。我还认为这是一个 hacky 解决方法,我想知道为什么我无法在网络上找到有关此问题的更多信息。

【讨论】:

  • 是的,我也采用了该解决方案,因为它已经一年多了,而且没有太多关注,我将把这个答案标记为解决方案。不确定您是否可以将另一个答案标记为某人的解决方案以及一个不那么老套的解决方案,但我不会为此屏住呼吸。
【解决方案2】:

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

【讨论】:

    猜你喜欢
    • 2014-01-04
    • 2013-07-15
    • 1970-01-01
    • 2015-08-13
    • 1970-01-01
    • 1970-01-01
    • 2012-01-31
    • 2021-12-15
    • 2012-02-11
    相关资源
    最近更新 更多