Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Module does not work with Android Auto, when there is no Activity #1231

Open
2 tasks done
SamuelBrucksch opened this issue Aug 5, 2024 · 0 comments
Open
2 tasks done
Labels

Comments

@SamuelBrucksch
Copy link

SamuelBrucksch commented Aug 5, 2024

Prerequisites

  • I checked the documentation and FAQ without finding a solution
  • I checked to make sure that this issue has not already been filed

Expected Behavior

It should work the same way as when using it for normal app development.

Current Behavior

When using it in combination with AA, there is no Activity. The activity seems to be required though, when creating a BleManager. Please see code snippet below on how to get it to work.

Library version

3.2.1

Device

Google Pixel 6

Environment info

---

Steps to reproduce

Run an Android Auto app with no app on the phone.

Formatted code sample or link to a repository

In file react-native-ble-plx/android/src/main/java/com/bleplx/BlePlxModule.java change

  public void createClient(String restoreStateIdentifier) {
    final Activity activity = getCurrentActivity();
    if (activity == null) {
      return;
    }

    bleAdapter = BleAdapterFactory.getNewAdapter(activity);

to

  public void createClient(String restoreStateIdentifier) {
    final Context applicationContext = getReactApplicationContext().getApplicationContext();
    if (applicationContext == null) {
      return;
    }

    bleAdapter = BleAdapterFactory.getNewAdapter(applicationContext);

Then it works again, however i don't know if this has any other side effects.

@SamuelBrucksch SamuelBrucksch changed the title 🐛 Module does not work with AndroidAuto, when there is no Activity 🐛 Module does not work with Android Auto, when there is no Activity Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant