2

I need some help for my app that I'm developing. Current code that I'm using, on long press it launches app info. I want to change that to launch an activity of my app.

The Quick.java class.

@TargetApi(24)
public class Quick extends TileService {

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    @Override
    public void onTileAdded() {
        super.onTileAdded();
    }

    @Override
    public void onTileRemoved() {
        super.onTileRemoved();
    }

    @Override
    public void onStartListening() {
        super.onStartListening();
    }

    @Override
    public void onStopListening() {
        super.onStopListening();
    }

    @Override
    public void onClick() {
        super.onClick();
        startActivity(Main);
    }
}

Just need a onLongClick() method on this code.

In my manifest under <application> tag.

        <service
            android:name=".Quick"
            android:icon="@drawable/ic_quick"
            android:label="@string/quick_title"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
            <intent-filter>
                <action android:name="android.service.quicksettings.action.QS_TILE" />
            </intent-filter>
        </service>

Caution : It's 100% possible to do that in android N and O, for an example take look at this app

ArghadipDasCEO
  • 177
  • 1
  • 12
  • Are you looking for app shorcuts then follow the link https://stackoverflow.com/a/48594233/9287163 – krishank Tripathi Feb 09 '18 at 16:03
  • If you want to create a tile service like quick setting then follow this link https://www.learn2crack.com/2017/02/android-using-quick-settings-tiles.html – krishank Tripathi Feb 09 '18 at 16:16
  • Well I know how to create a tile as well as how to set an activity onClick, I think you didn't read my question properly, I want to add a long click listener on the quick tile. Did you get it this time? – ArghadipDasCEO Feb 09 '18 at 16:21

1 Answers1

1

Ok I get yes you can implement the Long click listner but here is a issue 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>

As you have done in your manifest file here a link that might be helpfull look very closely long press quick setting tile in android

krishank Tripathi
  • 616
  • 1
  • 7
  • 23