Constructor uses

j _myprefs p' | Prefs instance public void run() { try {

FileOutputStream os = O Open a fi.le for getApplication () . openFileOutput ("sig. jpg", 0); <-1 storing signature sc.Save(os); os.flush(); os.close();

/ / reopen to so we can send this data to server File f = new

File(getApplication().getFileStreamPath("sig.jpg").toString()); long flength = f.length();

FileInputStream is = getApplication().openFileInput("sig.jpg"); byte data [] = new byte[(int) flength] ; int count = is.read(data); if (count != (int) flength) { // bad read?

msg.obj = (Object)("Connecting to Server"); progresshandler.sendMessage(msg);

URL url = new URL (_mypref s . getServer () + Q Construct

" /close j ob .php? j obid=" + j e . get_j obid () ) ; <—J storage URL URLConnection conn = url.openConnection(); conn.setDoOutput(true);

BufferedOutputStream wr = new © Write data Buff eredOutputStream (conn. getOutputStream () ) ; <1-' to server wr.write(data);

msg.obj = (Object)("Data Sent"); progresshandler.sendMessage(msg);

Buf feredReader rd = new Buff eredReader (new O Read server

^ InputStreamReader (conn.getlnputStream () ) ) ; <-1 response

String line = ""; Boolean bSuccess = false;

while ((line = rd. readLine () ) != null) { Q Check for successful if (line.indexOf ("SUCCESS") != -1) { <—J processing bSuccess = true;

msg.obj = (Object)("Job Closed Successfully");

progresshandler. sendMessage (msg) ; G Update local j e.set_status( "CLOSED" ) ; <—J JobEntry status

CloseJob. this . setResult (1, "", j e . toBundle () ) ; <1-1

0 0

Post a comment