2

It seems that every single method or property of accessing BluetoothAdapter instance would cause crashes on Instant Apps, even with android.permission.BLUETOOTH and android.permission.BLUETOOTH_ADMIN are added to AndroidManifest.xml. I know that I cannot find bluetooth releated permissions and operations here: https://developer.android.com/topic/google-play-instant/getting-started/instant-enabled-app-bundle I have also tried reflection way to trigger BluetoothAdapter.enable, but got InvocationTargetException. Wondering if there are any other workarounds? Thanks

OverflowStacker
  • 1,340
  • 1
  • 10
  • 17
Bob Tom
  • 21
  • 1

1 Answers1

3

You cannot use Bluetooth as an instant app.

The narrow list of permissible permissions shown at Supported permissions and operations give hint at the greater broad of the APIs that are restricted from being used in instant apps.

  • ACCESS_COARSE_LOCATION
  • ACCESS_FINE_LOCATION
  • ACCESS_NETWORK_STATE
  • BILLING – Deprecated as of Play Billing Library 1.0.
  • CAMERA
  • INSTANT_APP_FOREGROUND_SERVICE – Only in Android 8.0 (API level 26) and higher.
  • INTERNET
  • READ_PHONE_NUMBERS – Only in Android 8.0 (API level 26) and higher.
  • RECORD_AUDIO
  • VIBRATE
  • WAKE_LOCK

If you try to use a restricted API as an instant app, it'll typically cause an exception (SecurityException, etc..) or some denial of sort.

TWL
  • 6,228
  • 29
  • 65
  • So what if the full app uses Bluetooth - is it okay to have the Bluetooth permission in the manifest so it can be used by the full app, so long as that permission (and related API) are not invoked while it's running in Instant App mode? – wildcat12 Aug 17 '20 at 17:26
  • Ah, I found your other answer essentially saying that yes, you can declare different permissions for your installed app vs. Instant App, there's just a little nuance to it. https://stackoverflow.com/a/54097352/1119656 Thanks! – wildcat12 Aug 17 '20 at 19:08