|
| 1 | +package com.stacktips.example; |
| 2 | + |
| 3 | +import android.content.Intent; |
| 4 | +import android.service.quicksettings.TileService; |
| 5 | + |
| 6 | +/** |
| 7 | + * Created by Nilanchala Panigrahy on 8/10/16. |
| 8 | + */ |
| 9 | +public class MyAppTileService extends TileService { |
| 10 | + @Override |
| 11 | + public void onDestroy() { |
| 12 | + super.onDestroy(); |
| 13 | + } |
| 14 | + |
| 15 | + /** |
| 16 | + * Called when the tile is added to the quick settings from the edit interface by the user. If |
| 17 | + * you keep track of added tiles, override this and update it. |
| 18 | + * <p> |
| 19 | + * Return either TILE_MODE_ACTIVE or TILE_MODE_PASSIVE depending on your requirements |
| 20 | + */ |
| 21 | + @Override |
| 22 | + public void onTileAdded() { |
| 23 | + super.onTileAdded(); |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * Called when the tile is removed from the quick settings using the edit interface. Similarly |
| 28 | + * to onTileAdded, override this and update your tracking here if you need to |
| 29 | + */ |
| 30 | + @Override |
| 31 | + public void onTileRemoved() { |
| 32 | + super.onTileRemoved(); |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Called when the tile is brought into the listening state. Update it with your icon and title |
| 37 | + * here, using getQsTile to get the tile (see below) |
| 38 | + */ |
| 39 | + @Override |
| 40 | + public void onStartListening() { |
| 41 | + super.onStartListening(); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Called when the tile is brought out of the listening state. This represents when getQsTile |
| 46 | + * will now return null. |
| 47 | + */ |
| 48 | + @Override |
| 49 | + public void onStopListening() { |
| 50 | + super.onStopListening(); |
| 51 | + } |
| 52 | + |
| 53 | + /** |
| 54 | + * Called when the tile is clicked. Can be called multiple times in short succession, so double |
| 55 | + * click (and beyond) is possible |
| 56 | + */ |
| 57 | + @Override |
| 58 | + public void onClick() { |
| 59 | + super.onClick(); |
| 60 | + |
| 61 | + //Start main activity |
| 62 | + Intent intent = new Intent(this, MainActivity.class); |
| 63 | + startActivity(intent); |
| 64 | + } |
| 65 | +} |
0 commit comments