HBiSoft / HBRecorder

Lightweight screen recording Android library
MIT License
423 stars 141 forks source link

Lib not working on Android 12 #89

Closed robertlevonyan closed 3 years ago

robertlevonyan commented 3 years ago

Describe the bug Error on Android 12

Log Caused by java.lang.IllegalArgumentException: com.robertlevonyan.testy: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. Strongly consider using FLAG_IMMUTABLE, only use FLAG_MUTABLE if some functionality depends on the PendingIntent being mutable, e.g. if it needs to be used with inline replies or bubbles. at android.app.PendingIntent.checkFlags(PendingIntent.java:375) at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:645) at android.app.PendingIntent.getBroadcast(PendingIntent.java:632) at com.hbisoft.hbrecorder.ScreenRecordService.onStartCommand(ScreenRecordService.java:14) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:4632) at android.app.ActivityThread.access$1900(ActivityThread.java:247) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2084) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.app.ActivityThread.main(ActivityThread.java:7822) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

Can it be reproduced in demo app Yes

HBRecorder version for example 2.0.0

Device information

Pixel 3 XL 31

HBiSoft commented 3 years ago

Please try and change:

https://github.com/HBiSoft/HBRecorder/blob/a8207fe6b05f0a7701516ad83e881403e491130b/hbrecorder/src/main/java/com/hbisoft/hbrecorder/ScreenRecordService.java#L193

To this:

PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, myIntent, PendingIntent.FLAG_IMMUTABLE);
HBiSoft commented 3 years ago

Fixed in 2.0.1

robertlevonyan commented 3 years ago

thanks