android firebase file upload in background service stopped when clear app from recents.

Đang mở
#781 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
android, firebase, java
Lĩnh vực
mobile

Hướng nghiên cứu

Bắt đầu với ví dụ NotificationJobService trong issue, đặc biệt là onStartJob và onStopJob, rồi theo dõi cách UploadFileToServer được tạo và hủy khi ứng dụng bị xóa khỏi các ứng dụng gần đây. Payload không nêu tên tệp nào trong repository hay bài kiểm thử nào; được xem là hoàn thành khi các lượt tải lên nền và thông báo của chúng vẫn tiếp tục hoặc thất bại một cách rõ ràng sau khi ứng dụng bị xóa khỏi các ứng dụng gần đây.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

api: storage type: bug
Step 1: Are you in the right place?
  • For issues or feature requests related to the code android storage file a Github issue.
Step 2: Describe your environment
  • Android device: _____Mi note5
  • Android OS version: _____oreo
  • Google Play Services version: _____
  • Firebase/Play Services SDK version: _____
Step 3: Describe the problem:

I have used your code for file upload in background service. It works fine when the app is running. but when the app is removed from recent apps or get killed then the uploading and notification stopped and remains as it is.

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
public class NotificationJobService extends JobService implements UploadFileToServer.UploadEventListener {
    private JobStartedListner jobStartedListner;
    ArrayList<File> sourceFileList = new ArrayList<File>();
    UploadFileToServer uploadFileToServer;

    @Override
    public void onPreExecute() {

    }

    @Override
    public void onComplete() {

    }

    @Override
    public void onProgressUpdated(Integer progress, int totalSize, int currentFilePosition) {

    }

    public interface JobStartedListner {
        public void onJobStarted();
    }

    public NotificationJobService() {
    }

    @Override
    public boolean onStartJob(JobParameters jobParameters) {
        Log.e("Job Params", jobParameters.toString());
        String[] data = jobParameters.getExtras().getStringArray("data");
        for (int i = 0; i < data.length; i++) {
            if (data[i] != null) {
                File f = new File(data[i]);
                sourceFileList.add(new File(data[i]));
            }
        }
        uploadFiles(this, sourceFileList, this);
        return false;
    }

    public void uploadFiles(UploadFileToServer.UploadEventListener uploadEventListener, ArrayList<File> sourceFileList, Context context) {
        uploadFileToServer = new UploadFileToServer(uploadEventListener, /*new File(imagepath)*/sourceFileList, context);
    }

    @Override
    public boolean onStopJob(JobParameters jobParameters) {
        uploadFileToServer.cancel(true);
        return true;
    }
}
Ngôn ngữ chính
Kotlin
Star
9.3k
Fork
7.4k
Merge trung bình
7 ngày 9 giờ
Pull request đã merge (30 ngày)
6

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của firebase/quickstart-android

Tất cả issue của firebase/quickstart-android

Issue tương tự

Thêm issue về Kotlin

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.