Closed marvson closed 5 years ago
What device/OS version you test on?
The library itself uses Context.getApplicationContext()
inside on the Context
passed into RxBleClient.create(Context)
. I doubt that this is the problem. I see in the logs that the BT adapter state has changed but you do not mention it anywhere. Could you add more info?
The library itself uses Context.getApplicationContext() inside on the Context passed into RxBleClient.create(Context). I doubt that this is the problem
This helps a lot. I confirmed that it is OS related. It only happens in Miui 9.6.5, Android 7.1 Nougat. I tried in a Samsung with android 5.1 and it works just fine. And I found this explanation on stackoverflow link seems legit. And when I fixed the process, a thing that you can make in miui, it worked fine. Seems like it optimizes the process killing something important. No clue about what exactly happens but now I know how to fix it. Thank you.
I am happy that you have solve the problem
And when I fixed the process, a thing that you can make in miui
Could you add a bit more info that I could learn from? I do not know what you mean by fixed
I don't know the exact naming but "lock the proccess" is more like it. if you tap the button to show all opened apps and drag an app window down, then a lock appears in the top right of that window. It kind of protects the app from being optimized by miui, it also can't be terminated by android.
This actually was't what solved it to me. I just modified to not use dagger2 and to use the activity context, because I don't think it's a good thing asking the user to lock the app, since I can't do it programatically.
Weird... You're the first person who is mentioning this kind of a problem with Xiaomi devices. If you or someone else would find more information about the MIUI/Xiaomi implementation — feel free to share.
I see no way in which the library could change to help in this situation so I am closing now. If more info or a path forward will be available — feel free to add it and reopen
Summary
Library version
1.7.1
Preconditions
Using java 8, RxJava2 2.2.3, RxAndroid 2.1.0 with minSdkVersion 18
Steps to reproduce actual result
Using
rxBleClient = RxBleClient.create(this.getApplicationContext());
instead ofrxBleClient = RxBleClient.create(this);
Minimum code snippet reproducing the issue
Logs from the application running with setting
RxBleLog.setLogLevel(RxBleLog.VERBOSE)
The entire log is too big, these are the two parts regarding this issue:
Actual result
There is a spamming of a dead object exception and when we disconnect the bluetooth, there is an exception that doesn't happens when we use the activity context. I'm also unable to start any other scan, and the state change isn't captured.
Expected result
The state change is captured and the text "Bluetooth not enabled" is printed. Also there is no dead object exception.
Why this issue is important
I'm using dagger2 and I have access just to the application context when injecting this dependency (RxBleClient). I can easily fix this but in an ugly way.