Is there a way to set a Quick Settings Tile's default state?

試著忘記壹切 提交于 2020-01-04 11:03:03

问题


I'm messing around with the Quick Settings API in Android N / API 24, and while I think it's pretty well thought out, I can't seem to find a way to set a Tile's default state to Tile.STATE_ACTIVE...

I've tried setting the state in my service's onCreate method, but the getQsTile() method seems to return null at times.

Currently, I'm overriding onStartListening(), and am setting the state there, but this seems to cause a flickering effect most of the time.

Is this just something that isn't possible yet, or am I missing something?


回答1:


I've tried setting the state in my service's onCreate method, but the getQsTile() method seems to return null at times.

That's not how you do it anymore. Starting with NDP3 or NDP4, use META_DATA_ACTIVE_TILE:

<meta-data android:name="android.service.quicksettings.ACTIVE_TILE"
  android:value="true" />


来源:https://stackoverflow.com/questions/38019996/is-there-a-way-to-set-a-quick-settings-tiles-default-state

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!