Tag Archives: Attempted to finish an input event but the ~~~

[How to Solve] Attempted to finish an input event but the

This is an error reported:

04-806:36:48.372:W/InputEventReceiver(7867):Attemptedtofinishaninputeventbuttheinputeventreceiverhasalreadybeendisposed.
04-806:36:48.372:W/InputEventReceiver(7867):Attemptedtofinishaninputeventbuttheinputeventreceiverhasalreadybeendisposed.
04-806:36:48.372:I/Choreographer(7867):Skipped87frames!Theapplicationmaybedoingtoomuchworkonitsmainthread.
04-806:36:48.372:W/ViewRootImpl(7867):Droppingeventduetorootviewbeingremoved:MotionEvent{action=ACTION_UP,id[0]=0,x[0]=287.0,y[0]=-358.0,toolType[0]=TOOL_TYPE_FINGER,buttonState=0,metaState=0,flags=0x0,edgeFlags=0x0,pointerCount=1,historySize=0,eventTime=5442878,downTime=5442722,deviceId=0,source=0x1002}
04-806:37:31.392:I/uploadFile(7867):HTTPResponseis:InternalServerError:50001-1806:37:31.522:E/AsyncTime(7867):AsyncenteredPOSTTTT

This is the codes:

privateclassImageUploadTaskextendsAsyncTask<String,Void,String>{

privateStringwebAddressToPost="http://10.0.2.2:3000/wardrobe";

//FilesourceFile=newFile(imageview);
StringfileName="/sdcard/IMG_2016.JPG";
FilesourceFile=newFile(fileName);

HttpURLConnectionconn=null;
DataOutputStreamdos=null;
StringlineEnd="\r\n";
StringtwoHyphens="--";
Stringboundary="*****";
intbytesRead,bytesAvailable,bufferSize;
byte[]buffer;
intmaxBufferSize=1*1024*1024;

//privateProgressDialogdialog
privateProgressDialogprogressDialog=newProgressDialog(
wardrobe.this);

@Override
protectedvoidonPreExecute(){
Log.e("AsyncTime","Asyncentered1PREEE");
progressDialog.setMessage("Uploading...");
progressDialog.show();
}

@Override
protectedStringdoInBackground(String...arg0){
Log.e("AsyncTime","AsyncenteredDURINGG");
try{
//openaURLconnectiontotheServlet
FileInputStreamfileInputStream=newFileInputStream(
sourceFile);
URLurl=newURL(webAddressToPost);

//OpenaHTTPconnectiontotheURL
conn=(HttpURLConnection)url.openConnection();
conn.setDoInput(true);//AllowInputs
conn.setDoOutput(true);//AllowOutputs
conn.setUseCaches(false);//Don'tuseaCachedCopy
conn.setRequestMethod("POST");
conn.setRequestProperty("Connection","Keep-Alive");
conn.setRequestProperty("ENCTYPE","multipart/form-data");
conn.setRequestProperty("Content-Type",
"multipart/form-data;boundary="+boundary);
conn.setRequestProperty("uploaded_file",fileName);

dos=newDataOutputStream(conn.getOutputStream());

dos.writeBytes(twoHyphens+boundary+lineEnd);
dos.writeBytes("Content-Disposition:form-data;name=\"uploaded_file\";filename=\""
+fileName+"\""+lineEnd);

dos.writeBytes(lineEnd);

//createabufferofmaximumsize
bytesAvailable=fileInputStream.available();

bufferSize=Math.min(bytesAvailable,maxBufferSize);
buffer=newbyte[bufferSize];

//readfileandwriteitintoform...
bytesRead=fileInputStream.read(buffer,0,bufferSize);

while(bytesRead>0){

dos.write(buffer,0,bufferSize);
bytesAvailable=fileInputStream.available();
bufferSize=Math.min(bytesAvailable,maxBufferSize);
bytesRead=fileInputStream.read(buffer,0,bufferSize);

}

//sendmultipartformdatanecesssaryafterfiledata...
dos.writeBytes(lineEnd);
dos.writeBytes(twoHyphens+boundary+twoHyphens+lineEnd);

//Responsesfromtheserver(codeandmessage)
serverResponseCode=conn.getResponseCode();
StringserverResponseMessage=conn.getResponseMessage();

Log.i("uploadFile","HTTPResponseis:"
+serverResponseMessage+":"+serverResponseCode);

if(serverResponseCode==200){

Stringmsg="FileUploadCompleted.\n\nSeeuploadedfilehere:\n\n"
+"F:/wamp/wamp/www/uploads";
imageTextSelect.setText(msg);
Toast.makeText(wardrobe.this,"FileUploadComplete.",
Toast.LENGTH_SHORT).show();

}

//closethestreams//
fileInputStream.close();
dos.flush();
dos.close();
}catch(Exceptione){
e.printStackTrace();
}
returnnull;
}

@Override
protectedvoidonPostExecute(Stringresult){
Log.e("AsyncTime","AsyncenteredPOSTTTT");
progressDialog.dismiss();
Toast.makeText(getApplicationContext(),"fileuploaded",
Toast.LENGTH_LONG).show();
}
}

Solution:
Change String fileName = "/sdcard/IMG_2016.JPG";

to

String fileName = Environment.getExternalStorageDirectory().getAbsolutePath() + 
                            "/IMG_2016.JPG";