-
Notifications
You must be signed in to change notification settings - Fork 899
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
Solution of PendingIntent FLAG_IMMUTABLE exception on Android version 31 #485
Comments
Excellent solution, thanks. I had been looking for a solution for Android 12 for a while, reviewing my code, until I decided to see each library to see if they had the PendingIntent, and I found it. Hint: The MqttAndroidClient class, you have to implement the methods that it lacks, by default and it will work fine. Thanks. Make a pull request if you can, so it stays in the lib code. |
Great Solution thanks @huahua8893 |
Worked very well with a few modifications. |
When will there be an official solution to this problem? |
Using just a proof-of-concept hack app created with Android Studio Dolphin 2021.3.1 Patch 1, new project by "Empty Compose Activity"; then adding the android mqtt client service source code, as is (i.e org/eclipse/paho/android/service) to the "sample app" here: Without a doubt, this source should be a separate module and built accordingly with proper Gradle config, but I'm an newb and a totally lost puppy in this environment, so just scraping by to get a proof-of-concept running :-0 But most surprisingly, I had to stub out (or actually allow this incredibly intelligent Android Studio stub-out for me) 3 interface functions that were not overridden in MqttAndroidClient.java:
So now in addition to being lost, I am bewildered by how this could ever build before. |
Thnx bro @huahua8893. It works for me. |
But SCHEDULE_EXACT_ALARM permission is not allowed in android 12 ? |
Follow steps to build .aar or .jar file here if needed: |
@doorooful could you generate a release distributing the jars in your repository with the fixes? |
Can not run MqttService in background |
Good decision!
|
I have one small doubt here ..
but returning null . |
now I face the same question, I had to implements the two method. |
Like #480 #482 , I'm facing the same thing on Android version 31, but I can't change another repo to use in my project, so this is my solution:
1.Copy all "org.eclipse.paho:org.eclipse.paho.android.service" code one by one file into your project, keep original package path like this:
2.Modify class AlarmPingSender code like this:
3.Delete
implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
in build.gradle4.Add
implementation 'androidx.work:work-runtime:2.7.1'
to build.gradle5.Add
<uses-permission android:name="android.permission.SCHEDULE_EXACT_ALARM"/>
to manifest6.Everything ready to go
The text was updated successfully, but these errors were encountered: