问题
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