gotev / android-upload-service

Easily upload files (Multipart/Binary/FTP out of the box) in the background with progress notification. Support for persistent upload requests, customizations and custom plugins.
Apache License 2.0
2.83k stars 690 forks source link

Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. #637

Closed PeeyushShah closed 1 year ago

PeeyushShah commented 1 year ago

i have written the following code which was working fine

build.gradle: implementation 'net.gotev:uploadservice-okhttp:4.5.5'

activity : new MultipartUploadRequest(RachnaDetail.this, sUrl) .addFileToUpload(String.valueOf(sFilePath), "updcontent") .addParameter("data", sData) .setMaxRetries(2) .startUpload();

but it throws error :

2023-06-26 21:40:59.780 9773-9773/com.technoses.swargovindam D/SRRE: com.technoses.swargovindam: 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. 2023-06-26 21:40:59.781 9773-9773/com.technoses.swargovindam W/System.err: java.lang.IllegalArgumentException: com.technoses.swargovindam: Targeting S+ (version 31 and above) requires that one of FLAG_IMMUTABLE or FLAG_MUTABLE be specified when creating a PendingIntent. 2023-06-26 21:40:59.781 9773-9773/com.technoses.swargovindam W/System.err: 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. 2023-06-26 21:40:59.781 9773-9773/com.technoses.swargovindam W/System.err: at android.app.PendingIntent.checkFlags(PendingIntent.java:382) 2023-06-26 21:40:59.781 9773-9773/com.technoses.swargovindam W/System.err: at android.app.PendingIntent.getBroadcastAsUser(PendingIntent.java:673) 2023-06-26 21:40:59.781 9773-9773/com.technoses.swargovindam W/System.err: at android.app.PendingIntent.getBroadcast(PendingIntent.java:660) 2023-06-26 21:40:59.781 9773-9773/com.technoses.swargovindam W/System.err: at net.gotev.uploadservice.extensions.ContextExtensionsKt.getNotificationActionIntent(ContextExtensions.kt:203) 2023-06-26 21:40:59.781 9773-9773/com.technoses.swargovindam W/System.err: at net.gotev.uploadservice.extensions.ContextExtensionsKt.getCancelUploadIntent(ContextExtensions.kt:214) 2023-06-26 21:40:59.781 9773-9773/com.technoses.swargovindam W/System.err: at net.gotev.uploadservice.UploadServiceConfig$notificationConfigFactory$1.invoke(UploadServiceConfig.kt:141) 2023-06-26 21:40:59.781 9773-9773/com.technoses.swargovindam W/System.err: at net.gotev.uploadservice.UploadServiceConfig$notificationConfigFactory$1.invoke(UploadServiceConfig.kt:31) 2023-06-26 21:40:59.781 9773-9773/com.technoses.swargovindam W/System.err: at net.gotev.uploadservice.UploadRequest.startUpload(UploadRequest.kt:82) 2023-06-26 21:40:59.782 9773-9773/com.technoses.swargovindam W/System.err: at com.technoses.swargovindam.RachnaDetail$8$2.OnYes(RachnaDetail.java:315) 2023-06-26 21:40:59.782 9773-9773/com.technoses.swargovindam W/System.err: at com.technoses.swargovindam.swar$conn$2.onClick(swar.java:657) 2023-06-26 21:40:59.782 9773-9773/com.technoses.swargovindam W/System.err: at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:188) 2023-06-26 21:40:59.782 9773-9773/com.technoses.swargovindam W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106) 2023-06-26 21:40:59.782 9773-9773/com.technoses.swargovindam W/System.err: at android.os.Looper.loopOnce(Looper.java:226) 2023-06-26 21:40:59.782 9773-9773/com.technoses.swargovindam W/System.err: at android.os.Looper.loop(Looper.java:313) 2023-06-26 21:40:59.782 9773-9773/com.technoses.swargovindam W/System.err: at android.app.ActivityThread.main(ActivityThread.java:8663) 2023-06-26 21:40:59.782 9773-9773/com.technoses.swargovindam W/System.err: at java.lang.reflect.Method.invoke(Native Method) 2023-06-26 21:40:59.782 9773-9773/com.technoses.swargovindam W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:571) 2023-06-26 21:40:59.782 9773-9773/com.technoses.swargovindam W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1135) 2023-06-26 21:40:59.785 9773-9773/com.technoses.swargovindam I/MSHandlerLifeCycle: removeMultiSplitHandler: no exist. decor=DecorView@299ac49[RachnaDetail]

Please guide me to resolve this err

ubione88 commented 1 year ago

Hi, try adding a custom config to specify a new PendinIntent, this work for me

` //Create a new UploadNotificationConfig UploadNotificationConfig config = new UploadNotificationConfig(); //Add Flag config.setClickIntentForAllStatuses(PendingIntent.getBroadcast(context, 0, new Intent(),PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE));

//Add to Request new MultipartUploadRequest(RachnaDetail.this, sUrl) .addFileToUpload(String.valueOf(sFilePath), "updcontent") .addParameter("data", sData) .setMaxRetries(2) .setNotificationConfig(config) .startUpload(); `

I hope it helps

palicka commented 1 year ago

in the latest version I had to set it for all UploadNotificationStatusConfig configs, because there is no method setClickIntentForAllStatuses in UploadNotificationConfig, at least I don't see it there..

UploadNotificationConfig(
                        notificationChannelId = UploadServiceConfig.defaultNotificationChannel!!,
                        isRingToneEnabled = false,
                        progress = UploadNotificationStatusConfig(
                            title = ...,
                            message = ...,
                            clickIntent = PendingIntent.getBroadcast(
                                context,
                                0,
                                Intent(),
                                PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE
                            )
                        )
gotev commented 1 year ago

You're using version 4.5.5. Just update to at least 4.7.0.

PeeyushShah commented 1 year ago

Now notification showing error during upload. how to check.

PeeyushShah commented 1 year ago

You're using version 4.5.5. Just update to at least 4.7.0.

Now notification showing error during upload. how to check. i searched but no solution found. also when if use also when i want to use implements UploadStatusDelegate

it shows cannot resolved symbol

gotev commented 1 year ago

A way you can use to debug is with a global request observer: https://github.com/gotev/android-upload-service/wiki/Monitor-Uploads logging everything + break points for further detailed investigation