cloudinary/cloudinary_android

On Android oreo (Pixel device ) unable to upload image , unable to get callbacks in ListenerService

vikassminq opened this issue · 5 comments

I am using android sdk version :
implementation group: 'com.cloudinary', name: 'cloudinary-android', version: '1.24.0'

Hi @vikassminq ,

Could you please elaborate more on this issue and share with me the error stacktrace?

Cheers,
Yakir

HI @yakirp ,

Schedule one-off jobInfo success, request{id=7, tag=CLD, transient=false}, start 00:17:00, end 03:17:00 (from now), reschedule count 0

Below oero os , cloudinary sdk works fine for me , with ListenerService . but unable to get response in oero os in ListenerService , but getting requestId .

HI @yakirp ,

Calling from Activity class.
First i start service
startService(new Intent(this, UploadListner.class));
then I perform below operation .
String requestId = MediaManager.get().upload(mediaPath).unsigned("300x300")
.preprocess(new ImagePreprocessChain()
.saveWith(new BitmapEncoder(BitmapEncoder.Format.JPEG, 90)))
.policy(new UploadPolicy.Builder()
.maxRetries(3)
.backoffCriteria(300000, UploadPolicy.BackoffPolicy.LINEAR)
.networkPolicy(UploadPolicy.NetworkType.ANY)
.build())
.dispatch(this);

###########################################
In AndroidMaifest file register my service .

service
android:name="packagename.UploadListner" />

meta-data
android:name="cloudinaryCallbackService"
android:value="packagename.UploadListner" />

###########################################
In Background service performing below operation

public class UploadListner extends ListenerService {
public final static String VIDEO_STATUS = "Video_status";
public static final String UPLOAD_TYPE_VIDEO = "video";
public static final String UPLOAD_TYPE_IMAGE = "image";

NotificationManager notificationManager;
private NotificationCompat.Builder notificationBuilder;

@Override
public void onStart(String requestId) {

    // your code here
}

@Override
public void onProgress(String requestId, long bytes, long totalBytes) {
    // example code starts here
    Double progress = (double) bytes / totalBytes;
    // post progress to app UI (e.g. progress bar, notification)
   
}

@Override
public void onSuccess(String requestId, Map resultData) {
    // your code here
    LogUtils.d("UPLOAD::" + requestId);
    LogUtils.d("UPLOAD::" + resultData.get("public_id"));

    String[] parts = resultData.get("public_id").toString().split("/");

    String publicID = parts[1];
 }


@Override
public void onError(String requestId, ErrorInfo error) {
   
}

@Override
public void onReschedule(String requestId, ErrorInfo error) {
    // your code here
}

@Nullable
@Override
public IBinder onBind(Intent intent) {
    return null;
}

}

Hi @yakirp ,
same thing happen with UploadCallBack interface also .

String requestId = MediaManager.get().upload(mFilePath).unsigned("300x300")
.preprocess(new ImagePreprocessChain()
.saveWith(new BitmapEncoder(BitmapEncoder.Format.JPEG, 90)))
.policy(new UploadPolicy.Builder()
.maxRetries(3)
.backoffCriteria(300000, UploadPolicy.BackoffPolicy.LINEAR)
.networkPolicy(UploadPolicy.NetworkType.ANY)
.build())
.constrain(TimeWindow.immediate())

            .callback(new UploadCallback() {
                @Override
                public void onStart(String requestId) {
                    // your code here
                }

                @Override
                public void onProgress(String requestId, long bytes, long totalBytes) {
                    // example code starts here
                    Double progress = (double) bytes / totalBytes;
                    // post progress to app UI (e.g. progress bar, notification)
                    // example code ends here
                }

                @Override
                public void onSuccess(String requestId, Map resultData) {
                    // your code here
                    String[] parts = resultData.get("public_id").toString().split("/");

                    String publicID = parts[1];
                    System.out.println("UPLOAD::" + resultData.toString());
                    String uploadType = resultData.get("resource_type").toString();
                    String mVideoThumbnail = publicID + ".jpg";
                    String mVideoFileName = publicID + ".mp4";
                  
                }

                @Override
                public void onError(String requestId, ErrorInfo error) {
                    // your code here
                }

                @Override
                public void onReschedule(String requestId, ErrorInfo error) {
                    // your code here
                }
            })
            .dispatch(this);

JobProxy26: Schedule one-off jobInfo success, request{id=2, tag=CLD, transient=false}, start 00:00:00, end 03:00:00 (from now), reschedule count 0

After removing policy , it working fine .