czlucius / code-scanner

An Android app to scan and generate codes(barcodes/QR codes)
GNU Affero General Public License v3.0
39 stars 25 forks source link

Not discovering browsers on Android 11 when they are available. #3

Closed czlucius closed 3 years ago

czlucius commented 3 years ago

On Android 11, due to a package query limitation, the app cannot scan for other apps(e.g. browsers) that can open the URL, when the browsers are indeed on the device. This is due to <queries> declaration in AndroidManifest.xml not implemented properly, hence the app is not given permissions to scan for packages; intent.resolveActivity always returns null.

Steps to reproduce:

  1. Open the app
  2. Point the camera at a QR code/barcode which contains a web URL.
  3. Click the associated action, "Open link"

Expected behaviour: App redirects to browser, or displays a chooser dialog if multiple browsers are available, or displays a toast "No browsers found" when no browsers to open the QR code are found.

Actual behaviour: "No browsers found" displayed even when browsers are found. (see video attached)

Affected devices: All devices running Android 11 (API 30) and above.

Possible solutions

  1. Remove the queries tag and add a try-catch block, catching ActivityNotFoundException, when no browsers are found.
  2. Properly implement the queries tag, so that app has the proper permissions to scan for browsers (or apps with intent filter Intent.ACTION_VIEW)

https://user-images.githubusercontent.com/58442255/119657575-ac309380-be5e-11eb-84ac-9dbcccffc9ad.mp4