Android N: Quick Settings Tile API
Android N이 새로이 제공하는 Quick Settings Tile API를 이용하여 Quick Settings 영역에 어플의 tile을 추가할 수 있습니다. 아래 화면을 보면 Test tile이 추가되어 있죠.
import android.service.quicksettings.TileService;
public class MyTileService extends TileService {
...
}
|
public class MyTileService extends TileService {
@Override
public void onTileAdded() {
Log.d(LOG_TAG, "onTileAdded");
}
@Override
public void onTileRemoved() {
Log.d(LOG_TAG, "onTileRemoved");
}
@Override
public void onClick() {
Log.d(LOG_TAG, "onClick state = " +
Integer.toString(getQsTile().getState()));
}
}
|
<service
android:name=".MyTileService"
android:label="@string/tile_label"
android:icon="@drawable/ic_videocam"
android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
<intent-filter>
<action
android:name="android.service.quicksettings.action.QS_TILE"/>
</intent-filter>
</service>
|
@Override
public void onClick() {
Log.d(LOG_TAG, "onClick state = " +
Integer.toString(getQsTile().getState()));
Icon icon;
if (toggleState == STATE_ON) {
toggleState = STATE_OFF;
icon = Icon.createWithResource(getApplicationContext(),
R.drawable.ic_videocam_off);
} else {
toggleState = STATE_ON;
icon = Icon.createWithResource(getApplicationContext(),
R.drawable.ic_videocam);
}
getQsTile().setIcon(icon);
getQsTile().updateTile();
}
|