FileDocCategorySizeDatePackage
IntentTile.javaAPI DocAndroid 5.1 API6681Thu Mar 12 22:22:42 GMT 2015com.android.systemui.qs.tiles

IntentTile

public class IntentTile extends com.android.systemui.qs.QSTile

Fields Summary
public static final String
PREFIX
private android.app.PendingIntent
mOnClick
private String
mOnClickUri
private android.app.PendingIntent
mOnLongClick
private String
mOnLongClickUri
private int
mCurrentUserId
private final android.content.BroadcastReceiver
mReceiver
Constructors Summary
private IntentTile(Host host, String action)


         
        super(host);
        mContext.registerReceiver(mReceiver, new IntentFilter(action));
    
Methods Summary
public static com.android.systemui.qs.QSTilecreate(Host host, java.lang.String spec)

        if (spec == null || !spec.startsWith(PREFIX) || !spec.endsWith(")")) {
            throw new IllegalArgumentException("Bad intent tile spec: " + spec);
        }
        final String action = spec.substring(PREFIX.length(), spec.length() - 1);
        if (action.isEmpty()) {
            throw new IllegalArgumentException("Empty intent tile spec action");
        }
        return new IntentTile(host, action);
    
protected voidhandleClick()

        sendIntent("click", mOnClick, mOnClickUri);
    
protected voidhandleDestroy()

        super.handleDestroy();
        mContext.unregisterReceiver(mReceiver);
    
protected voidhandleLongClick()

        sendIntent("long-click", mOnLongClick, mOnLongClickUri);
    
protected voidhandleUpdateState(State state, java.lang.Object arg)

        if (!(arg instanceof Intent)) return;
        final Intent intent = (Intent) arg;
        state.visible = intent.getBooleanExtra("visible", true);
        state.contentDescription = intent.getStringExtra("contentDescription");
        state.label = intent.getStringExtra("label");
        state.icon = null;
        final byte[] iconBitmap = intent.getByteArrayExtra("iconBitmap");
        if (iconBitmap != null) {
            try {
                state.icon = new BytesIcon(iconBitmap);
            } catch (Throwable t) {
                Log.w(TAG, "Error loading icon bitmap, length " + iconBitmap.length, t);
            }
        } else {
            final int iconId = intent.getIntExtra("iconId", 0);
            if (iconId != 0) {
                final String iconPackage = intent.getStringExtra("iconPackage");
                if (!TextUtils.isEmpty(iconPackage)) {
                    state.icon = new PackageDrawableIcon(iconPackage, iconId);
                } else {
                    state.icon = ResourceIcon.get(iconId);
                }
            }
        }
        mOnClick = intent.getParcelableExtra("onClick");
        mOnClickUri = intent.getStringExtra("onClickUri");
        mOnLongClick = intent.getParcelableExtra("onLongClick");
        mOnLongClickUri = intent.getStringExtra("onLongClickUri");
    
protected voidhandleUserSwitch(int newUserId)

        super.handleUserSwitch(newUserId);
        mCurrentUserId = newUserId;
    
protected StatenewTileState()

        return new State();
    
private voidsendIntent(java.lang.String type, android.app.PendingIntent pi, java.lang.String uri)

        try {
            if (pi != null) {
                pi.send();
            } else if (uri != null) {
                final Intent intent = Intent.parseUri(uri, Intent.URI_INTENT_SCHEME);
                mContext.sendBroadcastAsUser(intent, new UserHandle(mCurrentUserId));
            }
        } catch (Throwable t) {
            Log.w(TAG, "Error sending " + type + " intent", t);
        }
    
public voidsetListening(boolean listening)