您需要创建自己的Tile
和TileService
来处理以下操作:
class CustomTileService: TileService(){
override fun onClick() {
super.onClick()
}
override fun onTileRemoved() {
super.onTileRemoved()
}
override fun onTileAdded() {
super.onTileAdded()
}
override fun onStartListening() {
super.onStartListening()
}
override fun onStopListening() {
super.onStopListening()
}
}
同时在清单文件中声明正确的权限:
<service
android:name=".CustomTileService"
android:icon="@drawable/tile_icon"
android:label="@string/tile_name"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action android:name="android.service.quicksettings.action.QS_TILE"/>
</intent-filter>
</service>