Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[android_intent] Make action optional, as Intents can also resolve with just the component name #2575

Merged
merged 5 commits into from
Mar 5, 2020

Conversation

ened
Copy link
Contributor

@ened ened commented Mar 4, 2020

Description

Android Intents can also be constructed with just the component name like so:

final Intent intent = new Intent();
intent.setComponent(componentName);
context.startActivity(intent);

Effectively, if the developer knows the target component, it can be called directly.

Related Issues

Preparation work for flutter/flutter#51942, which adds a "canResolve" method.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (flutter analyze) does not report any problems on my PR.
  • I read and followed the Flutter Style Guide.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy.
  • I updated CHANGELOG.md to add a description of the change.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • No, this is not a breaking change.

@matthew-carroll
Copy link
Contributor

Would you mind adding e2e tests that launch relevant Intent configurations to ensure that the platform side of the plugin operates correctly, too?

@ened
Copy link
Contributor Author

ened commented Mar 4, 2020

@matthew-carroll there are no e2e tests per se as they would launch another Android App potentially. There is a rather large unit test for the MethodHandler implementation that uses Robolectric to verify. I added an additional case in there for the "no-action, but component name" use case.

@ened ened merged commit 93a1c9b into flutter:master Mar 5, 2020
EdwinRomelta pushed a commit to EdwinRomelta/plugins that referenced this pull request Jun 11, 2020
…th just the component name (flutter#2575)

* An intent takes an action, component or both, but at least one of them.
* Extend the tests and enforce the new assertion on the private constructor as well
* Extends unit test to cover no-action, but component name case.
* Improves unit test even more by writing literal values in the code
FlutterSu pushed a commit to FlutterSu/flutter-plugins that referenced this pull request Nov 20, 2020
…th just the component name (flutter#2575)

* An intent takes an action, component or both, but at least one of them.
* Extend the tests and enforce the new assertion on the private constructor as well
* Extends unit test to cover no-action, but component name case.
* Improves unit test even more by writing literal values in the code
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants