Android异种机型系统适配:application定义的app名字和安装到手机后桌面显示app名字不一致

Android异种机型系统适配:application定义的app名字和安装到手机后桌面显示app名字不一致

这种情况在个别国内稀奇古怪定制化的Android机型上会出现。正常情况下,Android的App在桌面图标下方显示的名字由Androidmanifest.xml中,application的android:label属性值决定,比如:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app.zhangphil.app">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>


那么这个App安装到手机后,它在Android手机设备的桌面显示的名字是预先定义在res/values/string.xml中的app_name值,这是正常情况下的显示结果。
但是一些第三方手机厂商对于Android系统进行二次稀奇古怪的定制后,可能会引发意想不到的结果,比如明明在application中的android:label定义了App的名字,但是桌面显示的是一个过去缓存的或者什么别的名字。
解决这个问题的方案:可以重启手机试试。又或者把Androidmanifest.xml中,作为LAUNCHER的MAIN activity也设置成和application一致的android:label值,即作为MAIN  LAUNCHER启动的Activity中增加一样的android:label,比如:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="app.zhangphil.app">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

猜你喜欢

转载自blog.csdn.net/zhangphil/article/details/81485502