private Intent createProcessTextIntent() { return new Intent() .setAction(Intent.ACTION_PROCESS_TEXT) .setType("text/plain"); }
private List getSupportedActivities() { PackageManager packageManager = mTextView.getContext().getPackageManager(); return packageManager.queryIntentActivities(createProcessTextIntent(), 0); }
public void onInitializeMenu(Menu menu) { // Start with a menu Item order value that is high enough // so that your "PROCESS_TEXT" menu items appear after the // standard selection menu items like Cut, Copy, Paste. int menuItemOrder = 100; for (ResolveInfo resolveInfo : getSupportedActivities()) { menu.add(Menu.NONE, Menu.NONE, menuItemOrder++, getLabel(resolveInfo)) .setIntent(createProcessTextIntentForResolveInfo(resolveInfo)) .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); } }
resolveInfo.loadLabel(mPackageManager);
private Intent createProcessTextIntentForResolveInfo(ResolveInfo info) { return createProcessTextIntent() .putExtra(Intent.EXTRA_PROCESS_TEXT_READONLY, ! mTextView.isTextEditable()) .setClassName(info.activityInfo.packageName, info.activityInfo.name); }