Android IllegalStateException:内容已被使用 类VideoUploadTask扩展了AsyncTask{ @凌驾 受保护的字符串背景(无效…未指定){ 试一试{ Log.i(“视频上传任务”,“输入”); HttpClient HttpClient=新的DefaultHttpClient(); HttpContext localContext=新的BasicHttpContext(); HttpPost HttpPost=新的HttpPost( "http://192.168.5.10/ijoomer_development/index.php?option=com_ijoomer&plg_name=jomsocial&pview=album&ptask=upload_video&session_id=“+ConstantData.session_id+”); MultipartEntity=新的MultipartEntity(HttpMultipartMode.BROWSER_兼容); ByteArrayOutputStream bos=新建ByteArrayOutputStream(); //压缩(CompressFormat.JPEG,100,bos); 字节[]数据=bos.toByteArray(); Log.i(“视频上传中的categoryId”,即“+ConstantData.categoryId”); entity.addPart(“categoryId”,新的StringBody(ConstantData.categoryId.toString()); entity.addPart(“video”,新的ByteArrayBody(数据,“myvideo.mp4”); /* *entity.addPart(“photoCaption”),新增 *StringBody(caption.getText().toString()); */ httpPost.setEntity(实体); HttpResponse response=httpClient.execute(httpPost,localContext); InputStream in=response.getEntity().getContent(); BufferedReader reader=新的BufferedReader( 新的InputStreamReader( response.getEntity().getContent(),“UTF-8”); 字符串sResponse=reader.readLine(); 字符串strResponse=convertStreamToString(in); 系统输出打印项次(strResponse); if(dialog.isShowing()) dialog.dismise(); 返回strResponse; }捕获(例外e){ if(dialog.isShowing()) dialog.dismise(); //Toast.makeText(getApplicationContext(),“异常图像”,Toast.LENGTH_LONG.show(); Log.e(e.getClass().getName(),e.getMessage(),e); 返回null; } //(空); }

Android IllegalStateException:内容已被使用 类VideoUploadTask扩展了AsyncTask{ @凌驾 受保护的字符串背景(无效…未指定){ 试一试{ Log.i(“视频上传任务”,“输入”); HttpClient HttpClient=新的DefaultHttpClient(); HttpContext localContext=新的BasicHttpContext(); HttpPost HttpPost=新的HttpPost( "http://192.168.5.10/ijoomer_development/index.php?option=com_ijoomer&plg_name=jomsocial&pview=album&ptask=upload_video&session_id=“+ConstantData.session_id+”); MultipartEntity=新的MultipartEntity(HttpMultipartMode.BROWSER_兼容); ByteArrayOutputStream bos=新建ByteArrayOutputStream(); //压缩(CompressFormat.JPEG,100,bos); 字节[]数据=bos.toByteArray(); Log.i(“视频上传中的categoryId”,即“+ConstantData.categoryId”); entity.addPart(“categoryId”,新的StringBody(ConstantData.categoryId.toString()); entity.addPart(“video”,新的ByteArrayBody(数据,“myvideo.mp4”); /* *entity.addPart(“photoCaption”),新增 *StringBody(caption.getText().toString()); */ httpPost.setEntity(实体); HttpResponse response=httpClient.execute(httpPost,localContext); InputStream in=response.getEntity().getContent(); BufferedReader reader=新的BufferedReader( 新的InputStreamReader( response.getEntity().getContent(),“UTF-8”); 字符串sResponse=reader.readLine(); 字符串strResponse=convertStreamToString(in); 系统输出打印项次(strResponse); if(dialog.isShowing()) dialog.dismise(); 返回strResponse; }捕获(例外e){ if(dialog.isShowing()) dialog.dismise(); //Toast.makeText(getApplicationContext(),“异常图像”,Toast.LENGTH_LONG.show(); Log.e(e.getClass().getName(),e.getMessage(),e); 返回null; } //(空); },android,Android,获取错误IllegalStateException:内容已在log cat中使用了。我找不到什么问题。请帮助我更正此错误 非法状态异常的问题:内容已被消费已解决。但通过此编码,我无法上传视频。请给我一些建议。您调用getContent()两次: 使用中的创建读卡器 class VideoUploadTask extends AsyncTask<Void, Void, String> { @Override protected String doInBackground

获取错误IllegalStateException:内容已在log cat中使用了。我找不到什么问题。请帮助我更正此错误

非法状态异常的问题:内容已被消费已解决。但通过此编码,我无法上传视频。请给我一些建议。

您调用getContent()两次:

使用中的
创建读卡器

class VideoUploadTask extends AsyncTask<Void, Void, String> {
    @Override
    protected String doInBackground(Void... unsued) {
        try {
            Log.i("VideoUploadTask", "enters");

            HttpClient httpClient = new DefaultHttpClient();
            HttpContext localContext = new BasicHttpContext();
            HttpPost httpPost = new HttpPost(
                "http://192.168.5.10/ijoomer_development/index.php?option=com_ijoomer&plg_name=jomsocial&pview=album&ptask=upload_video&session_id="+ConstantData.session_id +"");
            MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            // bitmap.compress(CompressFormat.JPEG, 100, bos);
            byte[] data = bos.toByteArray();
            Log.i("categoryId in vedio upload2", ""+ConstantData.categoryId);
            entity.addPart("categoryId", new StringBody(ConstantData.categoryId.toString()));
            entity.addPart("video", new ByteArrayBody(data, "myvideo.mp4"));
            /*
             * entity.addPart("photoCaption", new
             * StringBody(caption.getText() .toString()));
             */
            httpPost.setEntity(entity);
            HttpResponse response = httpClient.execute(httpPost,localContext);
            InputStream in = response.getEntity().getContent();
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(
                            response.getEntity().getContent(), "UTF-8"));

            String sResponse = reader.readLine();

            String strResponse = convertStreamToString(in);
            System.out.println(strResponse);
            if (dialog.isShowing())
                dialog.dismiss();

            return strResponse;

        } catch (Exception e) {
            if (dialog.isShowing())
                dialog.dismiss();
            // Toast.makeText(getApplicationContext(),"Exception Image",Toast.LENGTH_LONG).show();
            Log.e(e.getClass().getName(), e.getMessage(), e);
            return null;
        }

        // (null);
    }
            InputStream in = response.getEntity().getContent();
            BufferedReader reader = new BufferedReader(
                    new InputStreamReader(
                            response.getEntity().getContent(), "UTF-8"));