App 更換應用圖標


一般情況下,我們App圖標在Androidmanifest.xml中設置,通過Application android:icon屬性指定,寫法如下:

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

    <application
        android:name=".ApplicationContext"
        android:allowBackup="false"
        android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:theme="@style/BaseTheme">

        ....
        .....

    </application>
</manifest>

因新年來臨等,產品需要針對最新版本更換一個應用圖標。OK,一分鍾搞定,如上,直接替換app_icon.png圖標即可。

然而,測試同學發現,替換圖標后,在小米5、華為6plus、樂視樂1S、小米2s、魅族MX5等手機上應用依然顯示以前圖標。

。。。。

 

取巧處理方法:

通過應用入口Activity android:icon屬性重新指定新圖標。目前通過測試,實測基本及時生效(部分機型自帶主題除外)。寫法如下:

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

    <application
        android:name=".core.application.ApplicationContext"
        android:allowBackup="false"
        android:icon="@drawable/app_icon"
        android:label="@string/app_name"
        android:theme="@style/BaseTheme">

        ....

        <activity
            android:name=".activity.MainActivity"
            android:icon="@drawable/new_app_icon"
            android:launchMode="singleTop"
            android:screenOrientation="portrait"
            android:theme="@style/BaseTheme.SplashScreen"
            android:configChanges="keyboardHidden|orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>


        .....

    </application>
</manifest>

通過入口Activity android:icon="@drawable/new_app_icon" 指向新的應用圖標。

 
         
         
       


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM