Я пытаюсь добавить переключатель быстрых настроек в свое приложение в Android N. Плитка быстрого доступа отображается, но при нажатии ничего не происходит. Я вижу видимую обратную связь при прикосновении, поэтому я знаю, что он распознает щелчок, но ничего не делает при нажатии.
Вот мой сервисный код:
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
}
}
В моем манифесте код почти напрямую скопирован из документации. Внесены лишь небольшие изменения:
<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>
Сервис запускается при открытии приложения:
Intent serviceIntent = new Intent(this, QuickSettingTileService.class);
startService(serviceIntent);
Toast
. - person CommonsWare   schedule 24.03.2016