4

I am new to android development. Trying to make a tile service, but I have trouble to overriding the default long press action.

For that, I have a class called QSTileService which extends TileService, and I want my tile to do different things depending on if you press or long press it. what ive found so far with buttons is to implement the OnLongClickListener interface and fill in what you want to do in the onLongClick method, but im not sure how to do this with quick setting tiles?

any help will be appreciated

pRaNaY
  • 24,642
  • 24
  • 96
  • 146
mk360
  • 51
  • 2
  • 3
  • Follow google codelab tutorial for Tile service: https://codelabs.developers.google.com/codelabs/android-n-quick-settings/index.html?index=..%2F..%2Findex#0 – pRaNaY Mar 10 '17 at 16:49
  • I went through the tutorial but I don't think it addressed how to modify the default long press action. My tile is a counter and I want it to increment the count on taps and reset on long press but I haven't been able to find a way to change the long press behaviour for it to reset, it always just goes to the app settings page – mk360 Mar 15 '17 at 05:01

1 Answers1

13

as per Documentation:

Long clicking on your quick settings tile will, by default, go to your app’s info screen. You can override that behavior by adding an intent-filter to one of your activities like so:

<intent-filter>
    <action android:name="android.service.quicksettings.action.QS_TILE_PREFERENCES"/>
</intent-filter>
Cilenco
  • 6,951
  • 17
  • 72
  • 152
  • Is it possible to make long pressing the tile do something like a broadcast, where I can just create a broadcast receiver to call a method? My goal is to have long pressing the tile reset a counter by calling a method as opposed to opening a new activity – mk360 Mar 28 '17 at 04:00
  • i am not sure if you can send a broadcast or starting service in background with same intent filter. But you can start a dummy transparent activity (or activity as a dialog) and immediately finish() the activity after broadcasting your event from onCreate method itself. But with this quick settings panel will be closed. you will need to drag again to see the panel. – Sandip Kothari Apr 03 '17 at 07:22