Quick Settings Toggle in Android N

Viewed 1616

I'm trying to add a quick settings toggle to my app in Android N. The quick tile shows up, but it doesn't do anything when clicked. I can see the visible feedback when touched, so I know that it is recognizing the click, but it doesn't do anything when clicked.

Here's my service code:

public class QuickSettingTileService extends TileService {

    public QuickSettingTileService()
    {
    }

    @Override
    public IBinder onBind(Intent intent)
    {
        return null;
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startID)
    {
        //some setup code is here

        return START_STICKY;
    }

    @Override
    public void onClick()
    {
        Context context = getApplicationContext();

        Toast.makeText(context, "Quick Setting Clicked", Toast.LENGTH_SHORT).show();
        //Toggle code is here
    }
}

My manifest has the code almost directly copied from the documentation. Only slight modifications have been made:

<service
    android:name=".QuickSettingTileService"
    android:label="@string/app_name"
    android:icon="@drawable/quick_toggle_off"
    android:permission="android.permission.BIND_QUICK_SETTINGS_TILE">
    <intent-filter>
        <action android:name="android.service.quicksettings.action.QS_TILE" />
    </intent-filter>
</service>

The service is started upon opening the app:

Intent serviceIntent = new Intent(this, QuickSettingTileService.class);
startService(serviceIntent);
1 Answers
Related