copy from android sdcard to windows share using samba jcifs

  • Replies:1
  • OpenNot stickiedUnanswered
  • Forum posts: 1

May 23, 2017 3:04:09 PM via Website

hi all iam trying to modifiy signature apk to send signature over wifi to windows share
signature was created but it cannot send automatically to windows share

private class MyCopy extends AsyncTask<String, String, String> {

    String z = "";
    String username = "", password = "", servername = "", filestocopy = "";

    @Override
    protected void onPreExecute() {
        SharedPreferences sharedPreferences = PreferenceManager
                .getDefaultSharedPreferences(context);

        String name = sharedPreferences.getString("storedName", "YourName");

        username = null;
        password = null;
        servername = "smb://" +name;
        filestocopy = "/sdcard/tanda_tangan/tanda_tangan.png";
    }


    @Override
    protected String doInBackground(String... params) {

        File A = new File(filestocopy);
        String filename = A.getName();

        NtlmPasswordAuthentication auth1 = new NtlmPasswordAuthentication(
                servername, username, password);

        try {

            SmbFile sfile = new SmbFile(servername + "/" + filename, auth1);
            //if (!sfile.exists())
               // sfile.createNewFile();
            sfile.connect();

            InputStream in = new FileInputStream(A);

            SmbFileOutputStream sfos = new SmbFileOutputStream(sfile);

            byte[] buf = new byte[1024];
            int len;
            while ((len = in.read(buf)) > 0) {
                sfos.write(buf, 0, len);
            }
            in.close();
            sfos.close();

            z = "File copied successfully";
        } catch (Exception ex) {

            z = z + " " + ex.getMessage().toString();
        }

        return z;
    }
}

what was wrong ?
pls help and this is the event
just tell me if you want whole project i will send it

 mGetSign.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {




            Log.v("tag", "Panel Saved");
            view.setDrawingCacheEnabled(true);
            mSignature.save(view, StoredPath);
            dialog.dismiss();
            Toast.makeText(getApplicationContext(), "sukses tersimpan", Toast.LENGTH_SHORT).show();

            MyCopy mycopy = new MyCopy();
            mycopy.execute("");


            recreate();
        }
    });
  • Forum posts: 18

May 23, 2017 8:59:51 PM via Website

I believe doInBackground returns message for you with error. Can you share what it is returning?