ShareAction extends Action { @NonNull @Override public ActionResult perform(@NonNull ActionArguments arguments) { final Context context = UAirship.getApplicationContext(); Intent sharingIntent = new Intent(Intent.ACTION_SEND) .setType("text/plain") .putExtra(Intent.EXTRA_TEXT, arguments.getValue().getString()); final Intent chooserIntent = Intent.createChooser(sharingIntent, context.getString(R.string.ua_share_dialog_title)) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(chooserIntent); return ActionResult.newEmptyResult(); }  @Override boolean acceptsArguments(@NonNull ActionArguments arguments); @NonNull @Override ActionResult perform(@NonNull ActionArguments arguments); @Override boolean shouldRunOnMainThread(); @NonNull
    static final String DEFAULT_REGISTRY_NAME; @NonNull
    static final String DEFAULT_REGISTRY_SHORT_NAME; }
@Test public void testPerform() { action.perform(ActionTestUtils.createArgs(Action.SITUATION_MANUAL_INVOCATION, "Share text")); Intent startedIntent = shadowOf(RuntimeEnvironment.application).getNextStartedActivity(); assertEquals(startedIntent.getAction(), Intent.ACTION_CHOOSER); assertEquals(startedIntent.getFlags(), Intent.FLAG_ACTIVITY_NEW_TASK); assertFalse(startedIntent.hasExtra(Intent.EXTRA_INITIAL_INTENTS)); Intent chooserIntent = startedIntent.getParcelableExtra(Intent.EXTRA_INTENT); assertEquals(chooserIntent.getStringExtra(Intent.EXTRA_TEXT), "Share text"); assertEquals(chooserIntent.getAction(), Intent.ACTION_SEND); assertEquals(null, chooserIntent.getPackage()); assertFalse(chooserIntent.hasExtra(Intent.EXTRA_INITIAL_INTENTS)); }