簡體   English   中英

為什么在安裝我的應用程序時輸入錯誤的快捷方式名稱?

[英]Why do I get the wrong shortcut name during installation of my app?

我最近將我的第一個應用程序發布到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>

我還看到了有關類似問題的其他問題,例如: 如何為啟動器而不是活動標題設置不同的標簽? 但是我的問題僅發生在上面指定的位置,手動創建的快捷方式和啟動器/程序菜單中的圖標都具有正確的名稱。

我所有快捷方式的期望名稱在以下位置指定:@ string / app_name而我不想要的名稱是:@ string / categories

有什么想法為什么會發生以及如何避免呢?

如果可能的話,我想避免將我的類別活動的標題更改為app_name,然后以編程方式在onCreate中更改標題的解決方案,因為我聽說這會導致在以編程方式設置標題之前不久顯示app_name顯示。

EDIT1:我試圖在盡可能小的環境中重新創建該問題,因此我創建了一個新的android項目並進行了必要的更改以說明該問題,然后將其作為“ Test App Store Shortcut”發布在Google Play上。 可以從以下網址下載: 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:我剛剛注意到,手動創建的快捷方式,如前所述,首先會給定正確的名稱,但是在設備重新啟動后,它們會得到錯誤的名稱。

我剛剛遇到了同樣的問題,最終將應用程序名稱設置為啟動器活動標簽,然后使用setTitle設置了實際的活動名稱。 如果您在super.onCreatesetContentView之前調用setTitle ,則應用名稱將不會在活動名稱之前super.onCreate 我還認為這是一個棘手的解決方法,想知道為什么我無法在網絡上找到更多有關此問題的信息。

我只是遇到了同樣的問題,我發現Appname正在使用我導入的庫Appname之一,因為我的應用沒有在res / values- [language]中設置語言的庫,但是庫中有語言,因此顯示了庫的appname。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM