FileDocCategorySizeDatePackage
LauncherActivity.javaAPI DocAndroid 5.1 API16873Thu Mar 12 22:22:10 GMT 2015android.app

LauncherActivity

public abstract class LauncherActivity extends ListActivity
Displays a list of all activities which can be performed for a given intent. Launches when clicked.

Fields Summary
android.content.Intent
mIntent
android.content.pm.PackageManager
mPackageManager
IconResizer
mIconResizer
Constructors Summary
Methods Summary
protected android.content.IntentgetTargetIntent()
Get the base intent to use when running {@link PackageManager#queryIntentActivities(Intent, int)}.

        return new Intent();
    
protected android.content.IntentintentForPosition(int position)
Return the actual Intent for a specific position in our {@link android.widget.ListView}.

param
position The item whose Intent to return

        ActivityAdapter adapter = (ActivityAdapter) mAdapter;
        return adapter.intentForPosition(position);
    
protected android.app.LauncherActivity$ListItemitemForPosition(int position)
Return the {@link ListItem} for a specific position in our {@link android.widget.ListView}.

param
position The item to return

        ActivityAdapter adapter = (ActivityAdapter) mAdapter;
        return adapter.itemForPosition(position);
    
public java.util.ListmakeListItems()
Perform the query to determine which results to show and return a list of them.

        // Load all matching activities and sort correctly
        List<ResolveInfo> list = onQueryPackageManager(mIntent);
        onSortResultList(list);

        ArrayList<ListItem> result = new ArrayList<ListItem>(list.size());
        int listSize = list.size();
        for (int i = 0; i < listSize; i++) {
            ResolveInfo resolveInfo = list.get(i);
            result.add(new ListItem(mPackageManager, resolveInfo, null));
        }

        return result;
    
protected voidonCreate(android.os.Bundle icicle)

        super.onCreate(icicle);
        
        mPackageManager = getPackageManager();

        if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
            requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
            setProgressBarIndeterminateVisibility(true);
        }
        onSetContentView();

        mIconResizer = new IconResizer();
        
        mIntent = new Intent(getTargetIntent());
        mIntent.setComponent(null);
        mAdapter = new ActivityAdapter(mIconResizer);

        setListAdapter(mAdapter);
        getListView().setTextFilterEnabled(true);

        updateAlertTitle();
        updateButtonText();

        if (!mPackageManager.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
            setProgressBarIndeterminateVisibility(false);
        }
    
protected booleanonEvaluateShowIcons()
Whether or not to show icons in the list

hide
keeping this private for now, since only Settings needs it
return
true to show icons beside the activity names, false otherwise

        return true;
    
protected voidonListItemClick(android.widget.ListView l, android.view.View v, int position, long id)

        Intent intent = intentForPosition(position);
        startActivity(intent);
    
protected java.util.ListonQueryPackageManager(android.content.Intent queryIntent)
Perform query on package manager for list items. The default implementation queries for activities.

        return mPackageManager.queryIntentActivities(queryIntent, /* no flags */ 0);
    
protected voidonSetContentView()
Override to call setContentView() with your own content view to customize the list layout.

        setContentView(com.android.internal.R.layout.activity_list);
    
protected voidonSortResultList(java.util.List results)

hide

        Collections.sort(results, new ResolveInfo.DisplayNameComparator(mPackageManager));
    
public voidsetTitle(java.lang.CharSequence title)

        super.setTitle(title);
        updateAlertTitle();
    
public voidsetTitle(int titleId)

        super.setTitle(titleId);
        updateAlertTitle();
    
private voidupdateAlertTitle()

        TextView alertTitle = (TextView) findViewById(com.android.internal.R.id.alertTitle);
        if (alertTitle != null) {
            alertTitle.setText(getTitle());
        }
    
private voidupdateButtonText()

        Button cancelButton = (Button) findViewById(com.android.internal.R.id.button1);
        if (cancelButton != null) {
            cancelButton.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    finish();
                }
            });
        }