簡體   English   中英

將 SDK 更新為 31 后,QuickSettings 中的磁貼不起作用

[英]Tile in QuickSettings not working after updating SDK to 31

在我的應用程序中,我們在 Android 的 QuickSettings 中有一個 Tile。它是一個可切換的 Tile。

它在 SDK 30 中運行良好,直到我將 SDK 更新為 31。我閱讀了文檔和 Android 12 中的更改,但我在我的代碼中找不到任何錯誤。 這是一些清單屬性,但我找不到解決方案。

行為是,如果我以 SDK 31 為目標,則 Tile 不可點擊且“不可用”。

清單的相關部分如下所示:

<service
        android:name="<mypackagename>.QuickSettingsTileService"
        android:exported="false"
        android:label="@string/app_name"
        android:icon="@drawable/<myapp>icon_on"
        android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
    <intent-filter>
        <action android:name="android.service.quicksettings.action.QS_TILE" />
    </intent-filter>
    <meta-data android:name="android.service.quicksettings.ACTIVE_TILE" android:value="true" />
</service>

所以,我找到了解決方案。 exported的屬性必須設置為true ,即:

android:exported="true"

在清單中。

實際上,從此處的文檔中引用:

If "true", the activity is accessible to any app, and is launchable by its exact class name.
If "false", the activity can be launched only by components of the same application, applications with the same user ID, or privileged system components. This is the default value when there are no intent filters.

我不會猜到這一點,因為我認為 Tile 是由某些特權系統組件管理的。

如果您有更多關於“為什么”我需要export服務的信息,請發表評論。

暫無
暫無

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

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