无法通过nougat版本的android将音频文件与数据一起上传到服务器

时间:2017-01-10 13:57:52

标签: android android-audiomanager android-7.0-nougat

我无法通过nougat版本的android将音频文件上传到服务器,音频通过媒体记录器录制并保存在设备上。这是代码,所有版本都适用android除了nogat之外,虽然在nogat中媒体被记录并保存在设备中,但它没有被上传到服务器上。

private void submitRecording() {
    CallLogsModel.idle++;
    final String filename = "file.MP3";
    final String path = Environment.getExternalStorageDirectory() + "/" + filename;

    JSONObject jObject = new JSONObject();
    String json = "";

    try {

        String uniquecode = PreferenceConfigration.getPreference(Constants.PreferenceConstants.UNIQUE_CODE);
        String token= UtilityMethods.tokenValue();
        Log.e("Token",token);
        jObject.put("uniquecode",uniquecode);

        jObject.put("lead_id", CallLogsModel.leads);
        jObject.put("duration",getAudioDuratiion());


        jObject.put("date_of_call", getDate());
        jObject.put("time_of_call",startTime);
        jObject.put("device", PreferenceConfigration.getPreference(Constants.PreferenceConstants.DEVICE).toString());
        jObject.put("token", token);
        Log.e("formed",jObject.toString());
        if (path.equals("") || path.equals(null) || path.equals("null")) {
            jObject.put("aboutphoto", "nophoto");
        }
        else
        {

        }
        json = jObject.toString();
    } catch (Exception e) {
    }
    Log.e("raisetic", json);
    OKhttpConnect.doPosttRequestWithMutipart("all_data", "attachment", "http://armsenterprise.com/api-new/kre-app/save_call_log.php", json, Environment.getExternalStorageDirectory() + "/" + filename, new HTTPcallback() {
        @Override
        public void onFailure(Request request, IOException e) {
            Log.e("Failure",e.toString());

        }

        @Override
        public void onResponse(final String response) {

            if (response != null && !(response.isEmpty())) {
                final JSONObject jsonObject;
                try
                {
                    CallLogsModel.idle++;
                    jsonObject = new JSONObject(response);
                    Log.e("ResponseCall", response);


                } catch (Exception e)
                {
                    e.printStackTrace();
                }

            } else {
                ((Activity) MainActivity.context).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(context, "Error in submission", Toast.LENGTH_SHORT).show();
                    }
                });

            }
        }
    });
    ((Activity) MainActivity.context).runOnUiThread(new Runnable() {
        @Override
        public void run() {
            Toast.makeText(MainActivity.context, "Raising Ticket ...", Toast.LENGTH_SHORT).show();
        }
    });




}

0 个答案:

没有答案