Pick an activity given an intent, returning the class selected.
Example: Pick an application
// Pick an application
Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
Intent pickIntent = new Intent(Intent.ACTION_PICK_ACTIVITY);
pickIntent.putExtra(Intent.EXTRA_INTENT, mainIntent);
startActivityForResult(pickIntent, 0);
// The result is obtained in onActivityResult:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (data != null) {
// launch the application that we just picked
startActivity(data);
}
}
Note: The PICK_ACTIVITY intent only works in SDK 1.5 or higher. In SDK 1.1 this code does not work.
A backward compatible implementation of the activity picker can be found in the source code of the OI Locale bridge.