Skip to content

android_intent_plus canResolveActivity with package name failure #245

Description

@doc-rj-celltrak

System info

Issue occurs on: Android
Plugin name: android_intent_plus
Plugin version: 1.0.1
Flutter doctor output:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 2.0.6, on macOS 11.3 20E232 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[✓] Xcode - develop for iOS and macOS
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.0)
[✓] Connected device (3 available)

• No issues found!

Steps to Reproduce

  1. Use the canResolveActivity() method with a package name for an app that is not installed. For example, if Chrome is not installed, but another browser is installed. Use this intent:

static const _chromeTestIntent = AndroidIntent(
action: 'android.intent.action.VIEW',
data: 'https://www.google.com',
package: 'com.android.chrome',
);

  1. canResolveActivity() will return true if any app can handle the intent's action. However, it should only return true if the Chrome package is installed and can handle the intent.

The problem is that the buildIntent() method is called from onMethodCall() before testing the intent. The buildIntent() method checks if the intent can be resolved and sets the package to null (removing the package condition) if it cannot.

    if (intent.resolveActivity(applicationContext.getPackageManager()) == null) {
        Log.i(TAG, "Cannot resolve explicit intent - ignoring package");
        intent.setPackage(null);
    }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions