Android 某些设备上的PDF文件未上载到我的服务器

Android 某些设备上的PDF文件未上载到我的服务器,android,android-volley,ion-koush,Android,Android Volley,Ion Koush,在我的应用程序中,用户将图像(转换为PDF)上传到我们的服务器, 我遇到的问题是,对于某些用户来说,在wifi或移动数据上,上传不起作用 这个应用程序在我的设备、几个模拟器和其他几个物理设备上运行得很好,但是上传对一些用户来说根本不起作用,我的意思是进度对话框会立即出现和消失,就好像没有数据被处理一样,这种情况偶尔发生,我完全被这个问题难住了 我使用Koush ION进行上传,其他与网络相关的功能(使用截图)工作得非常好,比如从服务器中提取JSON数据进行下拉等等 下面是上传和图像到PDF转换的

在我的应用程序中,用户将图像(转换为PDF)上传到我们的服务器, 我遇到的问题是,对于某些用户来说,在wifi或移动数据上,上传不起作用

这个应用程序在我的设备、几个模拟器和其他几个物理设备上运行得很好,但是上传对一些用户来说根本不起作用,我的意思是进度对话框会立即出现和消失,就好像没有数据被处理一样,这种情况偶尔发生,我完全被这个问题难住了 我使用Koush ION进行上传,其他与网络相关的功能(使用截图)工作得非常好,比如从服务器中提取JSON数据进行下拉等等

下面是上传和图像到PDF转换的代码 ''private void uploadImageToServer(){

final ProgressDialog pd=new ProgressDialog(SecondActivity.this);
pd.setMessage(“正在上载,请稍候…”);
pd.SetCanceledOnTouchOut(假);
pd.show();
PdfDocument document=新PdfDocument();
//用板条箱装一页说明
PdfDocument.PageInfo PageInfo;
PDF文档。第页;
帆布;
int i;
位图图像;
对于(i=0;i
当在这些设备上上传失败时,日志中是否有任何内容?这将发生在更高版本的Android上,您应该使用代码中提供的多部分和文件内容。什么都没有,只是简单地说是行不通的
        final ProgressDialog pd=new ProgressDialog(SecondActivity.this);
        pd.setMessage("Uploading, Please Wait....");
        pd.setCanceledOnTouchOutside(false);
        pd.show();


        PdfDocument document=new PdfDocument();
        // crate a page description
        PdfDocument.PageInfo pageInfo;
        PdfDocument.Page page;
        Canvas canvas;
        int i;
Bitmap image;



        for (i=0; i < list.size(); i++)  {


            pageInfo=new PdfDocument.PageInfo.Builder(992, 1432, 1).create();
            page=document.startPage(pageInfo);
            canvas=page.getCanvas();
            image=BitmapFactory.decodeFile(list.get(i));
            image = Bitmap.createScaledBitmap(image, 980, 1420, true);
            image.setDensity(DisplayMetrics.DENSITY_300);
            canvas.setDensity(DisplayMetrics.DENSITY_300);
            canvas.drawBitmap(image, 0, 0, null);
            document.finishPage(page);
        }
        @SuppressWarnings("deprecation") String directory_path=Environment.getExternalStorageDirectory().getPath() + "/mypdf/";
            File file=new File(directory_path);
            if (!file.exists()) {
                //noinspection ResultOfMethodCallIgnored
                file.mkdirs();
            }
            @SuppressLint("SimpleDateFormat") String timeStamp=(new SimpleDateFormat("yyyyMMdd_HHmmss")).format(new Date());
            String targetPdf=directory_path + timeStamp + ".pdf";
            File filePath=new File(targetPdf);
            try {
                document.writeTo(new FileOutputStream(filePath));

            } catch (IOException e) {
                Log.e("main", "error " + e.toString());
                Toasty.error(this, "Error making PDF" + e.toString(), Toast.LENGTH_LONG).show();
            }
            // close the document
            document.close();



        CheckBox chk=findViewById(R.id.chk1);
        if (chk.isChecked()) {
            Uri.Builder builder=new Uri.Builder();
            builder.scheme("https")
                    .authority("www.smartpractice.co.za")
                    .appendPath("files-upload-phone-app.asp")
                    .appendQueryParameter("MyForm", "Yes")
                    .appendQueryParameter("ClientID", clientId)
                    .appendQueryParameter("Username", email)
                    .appendQueryParameter("Pwd", pwd)
                    .appendQueryParameter("Category", Item)
                    .appendQueryParameter("ClientName", Item2)
                    .appendQueryParameter("NoEmail", "Yes");
            myURL=builder.build().toString();
        } else {
            Uri.Builder builder4=new Uri.Builder();
            builder4.scheme("https")
                    .authority("www.smartpractice.co.za")
                    .appendPath("files-upload-phone-app.asp")
                    .appendQueryParameter("MyForm", "Yes")
                    .appendQueryParameter("ClientID", clientId)
                    .appendQueryParameter("Username", email)
                    .appendQueryParameter("Pwd", pwd)
                    .appendQueryParameter("Category", Item)
                    .appendQueryParameter("ClientName", Item2)
                    .appendQueryParameter("NoEmail", "");

            myURL=builder4.build().toString();
        }



        Ion.with(SecondActivity.this)
                .load(myURL)
                .setTimeout(360000000)
                .uploadProgressDialog(pd)
                .setMultipartFile("pdf","pdf/*",filePath )
                .asJsonObject()

                .setCallback(new FutureCallback<JsonObject>()
                {
                    @Override
                    public void onCompleted(Exception e, JsonObject result) {

                        String message = result.get("message").getAsString();
                        Toasty.info(SecondActivity.this, message, Toast.LENGTH_LONG).show();
                        Button upload=findViewById(R.id.upload);
                        upload.setText(message);
                        pd.cancel();


                        }
                        });


    }