App不顯示桌面圖標

最近調試App,運行之後一切正常,可是退出App之後,手機桌面上卻找不到App的圖標。到應用程序裏去找,倒是可以找到。

在網上查了一些資料,終於找到原因:

最近在App的啓動頁添加了Scheme跳轉功能,於是在AndroidManifest.xml文件中,啓動頁的配置如下:

<activity
    android:name=".splash.SplashActivity"
    android:screenOrientation="portrait"
    android:theme="@style/Splash.Fullscreen"
    android:windowSoftInputMode="stateAlwaysHidden">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />

        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="thescheme" />
    </intent-filter>
</activity>

其中<intent-filter>裏前面的兩項用來表明此Activity是App的啓動頁, 而後面三項用來定義Activity的scheme跳轉。把這些配置一股腦放進一個<intent-filter>, 可能會造成覆蓋和混亂,具體原因不明瞭。解決辦法是它們分開放到不同的<intent-filter>中,如下:

<activity
    android:name=".splash.SplashActivity"
    android:screenOrientation="portrait"
    android:theme="@style/Splash.Fullscreen"
    android:windowSoftInputMode="stateAlwaysHidden">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>

    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="thescheme" />
    </intent-filter>
</activity>

如此,桌面圖標就回來了。

參考:
Android程序安裝後應用圖標不顯示的問題
Adding a data scheme to the manifest in in the app, hides the app

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章