1

How to modify status bar in Android Pie AOSP? I want to add some custom icons along with the existing icons like battery, network signal, etc. Also i want to know which files I have to edit to add and remove quick setting tiles programmatically.

  1. Thinking that there are no quick setting tiles by default, how do i add only wifi, bluetooth and gps quick setting tile programmatically??
  2. How to add expanded layouts for wifi and bluetooth settings in their respective tiles so that on click of the tile, i can show existing wifi networks and bluetooth devices??
  3. Where is the code for getting the list of wifi networks and bluetooth devices located?
  4. How do i implement a callback so that if i switch on wifi and connect to a network, the wifi icon in the status bar becomes visible?? How do i proceed if i want the same behaviour for a custom icon in the status bar??
sudupa
  • 23
  • 1
  • 8

1 Answers1

1

Given your question I think you are talking about Quick Settings tiles. To make a Quick Settings tile, your class must extend TileService: public class HSTileService extends TileService. TileService has several methods you must implement: public void onClick(), public void onTileRemoved(), public void onTileAdded(), public void onStartListening(), and public void onStopListening().

onStartListening is called when the tile comes into view, and onStopListening is called when it leaves the view. All of these methods must call super.<method_name> as their first action.

To acquire the QSTile object that you manipulate to change the tile's state, use Tile tile = getQsTile(); To set the state, use tile.setState(), which takes Tile.STATE_ACTIVE, Tile.STATE_INACTIVE, or Tile.STATE_DISABLED as an argument. After changing the tile's state, ensure that you call tile.updateTile() or it will not update.

To get the tile state, use tile.getState()

Finally, you'll need the following imports:

import android.app.ActivityManager;
import android.content.Context;
import android.graphics.drawable.Icon;
import android.os.Build;
import android.service.quicksettings.Tile;
import android.service.quicksettings.TileService;
import android.content.Intent;
import android.util.Log;

If you need further assistance, note that all of this and more can be found on the AOSP docs as well as here: https://medium.com/androiddevelopers/quick-settings-tiles-e3c22daf93a8

Connor
  • 143
  • 1
  • 11