本文整理匯總了Java中android.service.quicksettings.Tile.getState方法的典型用法代碼示例。如果您正苦於以下問題:Java Tile.getState方法的具體用法?Java Tile.getState怎麽用?Java Tile.getState使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.service.quicksettings.Tile
的用法示例。
在下文中一共展示了Tile.getState方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onClick
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
super.onClick();
Tile tile = getQsTile();
switch (tile.getState()) {
case Tile.STATE_INACTIVE:
startServer();
updateTileState(Tile.STATE_ACTIVE);
break;
case Tile.STATE_ACTIVE:
stopServer();
default:
updateTileState(Tile.STATE_INACTIVE);
break;
}
}
示例2: onClick
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
Tile tile = getQsTile();
App utils = (App) getApplicationContext();
if (tile.getState() == Tile.STATE_ACTIVE) {
if (utils.StartShowWin) {
tile.setState(Tile.STATE_INACTIVE);
FloatManageMethod.ShutDown(this);
} else {
tile.setState(Tile.STATE_INACTIVE);
}
} else if (tile.getState() == Tile.STATE_INACTIVE) {
if (utils.StartShowWin) {
tile.setState(Tile.STATE_ACTIVE);
} else {
if (QuickStartMethod.Launch(this)) {
tile.setState(Tile.STATE_ACTIVE);
}
}
}
tile.updateTile();
super.onClick();
}
示例3: onClick
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
super.onClick();
Log("Clicked");
initPrefs();
Tile tile = getQsTile();
if (tile != null) {
switch (tile.getState()) {
case Tile.STATE_ACTIVE:
prefs.setBool(Prefs.KEYS.ENABLED.toString(), false);
setCurrentState(Tile.STATE_INACTIVE);
break;
case Tile.STATE_INACTIVE:
prefs.setBool(Prefs.KEYS.ENABLED.toString(), true);
setCurrentState(Tile.STATE_ACTIVE);
break;
default:
tile.setLabel(getString(R.string.quick_settings_title) + " " + (prefs.enabled ? getString(R.string.quick_settings_service_active) : getString(R.string.quick_settings_service_inactive)));
Log("Active");
break;
}
} else {
Log("Tile is null");
}
}
示例4: onClick
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
super.onClick();
Log.d(TAG, "onClick");
Tile tile = getQsTile();
if (tile != null) {
if (tile.getState() == Tile.STATE_ACTIVE) {
tile.setLabel("QuickStart");
tile.setState(Tile.STATE_INACTIVE);
} else {
tile.setLabel("Running...");
tile.setState(Tile.STATE_ACTIVE);
}
tile.updateTile();
}
}
示例5: onClick
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick(){
Log.d(TAG, "Tile service onClick method called");
super.onClick();
Tile tile = getQsTile();
if (tile == null) return;
int status = tile.getState();
Log.d(TAG, "status:" + status + "\t receive");
switch (status) {
case Tile.STATE_INACTIVE:
ActionReceiver.sendActionStart(this);
updateActiveTile(tile);
break;
case Tile.STATE_ACTIVE:
ActionReceiver.sendActionStop(this);
updateInactiveTile(tile);
break;
}
}
示例6: onClick
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
Tile nightMode = getQsTile();
int state;
try {
state = nightMode.getState();
if (state == Tile.STATE_ACTIVE) {
if (Build.VERSION.SDK_INT == 24) {
Settings.Secure.putInt(getContentResolver(), "twilight_mode", 0);
} else {
Settings.Secure.putInt(getContentResolver(), NIGHT_DISPLAY_ACTIVATED, 0);
}
nightMode.setState(Tile.STATE_INACTIVE);
} else {
if (Build.VERSION.SDK_INT == 24) {
Settings.Secure.putInt(getContentResolver(), "twilight_mode", 1);
} else {
Settings.Secure.putInt(getContentResolver(), NIGHT_DISPLAY_ACTIVATED, 1);
}
nightMode.setState(Tile.STATE_ACTIVE);
}
mToggleIntent.putExtra("state", state == Tile.STATE_INACTIVE);
sendBroadcast(mToggleIntent);
} catch (Exception e) {
e.printStackTrace();
}
nightMode.updateTile();
}
示例7: onClick
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
super.onClick();
Tile tile = getQsTile();
if (!ImmersiveModeUtils.hasSecureSettingsPermission(this.getApplicationContext())) {
tile.setState(Tile.STATE_UNAVAILABLE);
tile.updateTile();
}
switch (tile.getState()) {
case Tile.STATE_UNAVAILABLE:
showToast("Unable to toggle immersive mode. Open ImmersiveModeUtils for more details.");
break;
case Tile.STATE_ACTIVE:
// Disable immersive mode
if (ImmersiveModeUtils.disableImmersiveMode(this.getApplicationContext())) {
tile.setState(Tile.STATE_INACTIVE);
tile.updateTile();
} else {
showToast("Unable to disable immersive mode due to unknown error.");
}
break;
case Tile.STATE_INACTIVE:
// Enable immersive mode
if (ImmersiveModeUtils.enableImmersiveMode(this.getApplicationContext())) {
tile.setState(Tile.STATE_ACTIVE);
tile.updateTile();
} else {
showToast("Unable to enable immersive mode due to unknown error.");
}
break;
}
}
示例8: updateView
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void updateView(boolean displayToast, boolean init) {
Tile tile = getQsTile();
if (BaseMethod.isAccessibilitySettingsOn(this)) {
boolean KeyBlocked = PreferenceManager.getDefaultSharedPreferences(this).getBoolean(Config.ENABLED_KEYBLOCK, false);
if (init) {
if (KeyBlocked) {
tile.setState(Tile.STATE_ACTIVE);
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_blocked));
} else {
tile.setState(Tile.STATE_INACTIVE);
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_not_blocked));
}
} else {
if (tile.getState() == Tile.STATE_ACTIVE) {
tile.setState(Tile.STATE_INACTIVE);
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_not_blocked));
} else if (tile.getState() == Tile.STATE_INACTIVE) {
tile.setState(Tile.STATE_ACTIVE);
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_blocked));
}
}
} else {
tile.setState(Tile.STATE_INACTIVE);
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notification_not_blocked));
if (displayToast) {
BaseMethod.RunAccessibilityService(this);
}
}
tile.updateTile();
}
示例9: onClick
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
/**
* Called when the tile is clicked, regardless of its current state
*/
@Override
public void onClick()
{
super.onClick();
Tile tile = getQsTile();
switch (tile.getState())
{
case Tile.STATE_ACTIVE:
{
setTileState(Tile.STATE_INACTIVE, tile);
// Code to turn off something, in this case, the service that draws the grid overlay
// getApplicationContext().stopService(new Intent(this, KeylineGridService.class));
break;
}
case Tile.STATE_INACTIVE:
{
setTileState(Tile.STATE_ACTIVE, tile);
// Code to turn on something, in this case, the service that draws the grid overlay
// getApplicationContext().startService(new Intent(this, KeylineGridService.class));
break;
}
case Tile.STATE_UNAVAILABLE:
{
setTileState(Tile.STATE_UNAVAILABLE, tile);
// Code to handle cases in which the tile is unavailable
break;
}
}
}
示例10: onStartListening
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onStartListening() {
super.onStartListening();
Log.d(TAG, "onStartListening");
Tile tile = getQsTile();
if (tile != null) {
if (tile.getState() == Tile.STATE_ACTIVE) {
tile.setLabel("Running...");
} else {
tile.setLabel("QuickStart");
}
tile.updateTile();
}
}
示例11: onClick
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
// Check to see if the device is currently locked.
boolean isCurrentlyLocked = this.isLocked();
if (!isCurrentlyLocked) {
Resources resources = getApplication().getResources();
Tile tile = getQsTile();
String tileLabel = tile.getLabel().toString();
String tileState = (tile.getState() == Tile.STATE_ACTIVE) ?
resources.getString(R.string.service_active) :
resources.getString(R.string.service_inactive);
Intent intent = new Intent(getApplicationContext(),
ResultActivity.class);
intent.putExtra(ResultActivity.RESULT_ACTIVITY_NAME_KEY,
tileLabel);
intent.putExtra(ResultActivity.RESULT_ACTIVITY_INFO_KEY,
tileState);
startActivityAndCollapse(intent);
}
}
示例12: updateTile
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
private void updateTile(Source source) {
Tile tile = getQsTile();
if (tile == null) {
// We're outside of the onStartListening / onStopListening window
// We'll update the tile next time onStartListening is called.
return;
}
if (!mWallpaperActive && tile.getState() != Tile.STATE_INACTIVE) {
// If the wallpaper isn't active, the quick tile will activate it
tile.setState(Tile.STATE_INACTIVE);
tile.setLabel(getString(R.string.action_activate));
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_stat_muzei));
tile.updateTile();
return;
}
if (source == null) {
return;
}
if (source.supportsNextArtwork) {
tile.setState(Tile.STATE_ACTIVE);
tile.setLabel(getString(R.string.action_next_artwork));
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notif_full_next_artwork));
} else {
tile.setState(Tile.STATE_UNAVAILABLE);
tile.setLabel(getString(R.string.action_next_artwork));
tile.setIcon(Icon.createWithResource(this, R.drawable.ic_notif_full_next_artwork));
}
tile.updateTile();
}
示例13: onClick
import android.service.quicksettings.Tile; //導入方法依賴的package包/類
@Override
public void onClick() {
Tile tile = getQsTile();
if (tile == null) {
// We're outside of the onStartListening / onStopListening window,
// ignore late arriving clicks
return;
}
if (tile.getState() == Tile.STATE_ACTIVE) {
FirebaseAnalytics.getInstance(NextArtworkTileService.this).logEvent(
"tile_next_artwork_click", null);
// Active means we send the 'Next Artwork' command
SourceManager.sendAction(this, MuzeiArtSource.BUILTIN_COMMAND_ID_NEXT_ARTWORK);
} else {
// Inactive means we attempt to activate Muzei
unlockAndRun(() -> {
FirebaseAnalytics.getInstance(NextArtworkTileService.this).logEvent(
"tile_next_artwork_activate", null);
try {
startActivityAndCollapse(new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER)
.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
new ComponentName(NextArtworkTileService.this,
MuzeiWallpaperService.class))
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} catch (ActivityNotFoundException e) {
try {
startActivityAndCollapse(new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER)
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
} catch (ActivityNotFoundException e2) {
Toast.makeText(NextArtworkTileService.this, R.string.error_wallpaper_chooser,
Toast.LENGTH_LONG).show();
}
}
});
}
}