FileDocCategorySizeDatePackage
HeavyWeightSwitcherActivity.javaAPI DocAndroid 5.1 API6092Thu Mar 12 22:22:10 GMT 2015com.android.internal.app

HeavyWeightSwitcherActivity

public class HeavyWeightSwitcherActivity extends android.app.Activity
This activity is displayed when the system attempts to start an Intent for which there is more than one matching activity, allowing the user to decide which to go to. It is not normally used directly by application developers.

Fields Summary
public static final String
KEY_INTENT
The PendingIntent of the new activity being launched.
public static final String
KEY_HAS_RESULT
Set if the caller is requesting a result.
public static final String
KEY_CUR_APP
Package of current heavy-weight app.
public static final String
KEY_CUR_TASK
Task that current heavy-weight activity is running in.
public static final String
KEY_NEW_APP
Package of newly requested heavy-weight app.
android.content.IntentSender
mStartIntent
boolean
mHasResult
String
mCurApp
int
mCurTask
String
mNewApp
private android.view.View.OnClickListener
mSwitchOldListener
private android.view.View.OnClickListener
mSwitchNewListener
private android.view.View.OnClickListener
mCancelListener
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle savedInstanceState)

    
    
        
        super.onCreate(savedInstanceState);
        
        requestWindowFeature(Window.FEATURE_LEFT_ICON);
        
        mStartIntent = (IntentSender)getIntent().getParcelableExtra(KEY_INTENT);
        mHasResult = getIntent().getBooleanExtra(KEY_HAS_RESULT, false);
        mCurApp = getIntent().getStringExtra(KEY_CUR_APP);
        mCurTask = getIntent().getIntExtra(KEY_CUR_TASK, 0);
        mNewApp = getIntent().getStringExtra(KEY_NEW_APP);
        
        setContentView(com.android.internal.R.layout.heavy_weight_switcher);
        
        setIconAndText(R.id.old_app_icon, R.id.old_app_action, R.id.old_app_description,
                mCurApp, R.string.old_app_action, R.string.old_app_description);
        setIconAndText(R.id.new_app_icon, R.id.new_app_action, R.id.new_app_description,
                mNewApp, R.string.new_app_action, R.string.new_app_description);
            
        View button = findViewById((R.id.switch_old));
        button.setOnClickListener(mSwitchOldListener);
        button = findViewById((R.id.switch_new));
        button.setOnClickListener(mSwitchNewListener);
        button = findViewById((R.id.cancel));
        button.setOnClickListener(mCancelListener);
        
        TypedValue out = new TypedValue();
        getTheme().resolveAttribute(android.R.attr.alertDialogIcon, out, true);
        getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, 
                out.resourceId);
    
voidsetDrawable(int id, android.graphics.drawable.Drawable dr)

        if (dr != null) {
            ((ImageView)findViewById(id)).setImageDrawable(dr);
        }
    
voidsetIconAndText(int iconId, int actionId, int descriptionId, java.lang.String packageName, int actionStr, int descriptionStr)

        CharSequence appName = "";
        Drawable appIcon = null;
        if (mCurApp != null) {
            try {
                ApplicationInfo info = getPackageManager().getApplicationInfo(
                        packageName, 0);
                appName = info.loadLabel(getPackageManager());
                appIcon = info.loadIcon(getPackageManager());
            } catch (PackageManager.NameNotFoundException e) {
            }
        }
        
        setDrawable(iconId, appIcon);
        setText(actionId, getString(actionStr, appName));
        setText(descriptionId, getText(descriptionStr));
    
voidsetText(int id, java.lang.CharSequence text)

        ((TextView)findViewById(id)).setText(text);