private void uploadFiles() { Toast.makeText(this, "trying to upload files", Toast.LENGTH_SHORT).show(); List<String> fileList = getFileList(getIntent()); for (String path : fileList) { File file = new File(path); if (file.exists()) { UploadPicture uploadPicture = new UploadPicture(this, mApi, PHOTO_DIR, file); uploadPicture.execute(); } else { Toast.makeText(this, "file does not exist: " + path, Toast.LENGTH_SHORT).show(); } } }
// This is what gets called on finishing a media piece to import @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (requestCode == NEW_PICTURE) { // return from file upload if (resultCode == Activity.RESULT_OK) { Uri uri = null; if (data != null) { uri = data.getData(); } if (uri == null && mCameraFileName != null) { uri = Uri.fromFile(new File(mCameraFileName)); } File file1 = new File(mCameraFileName); if (uri != null) { UploadPicture upload = new UploadPicture(this, mApi, PHOTO_DIR, file1); upload.execute(); GridView gridview = (GridView) findViewById(R.id.gridview); myImageAdapter = new ImageAdapter(this); gridview.setAdapter(myImageAdapter); String ExternalStorageDirectoryPath = Environment.getExternalStorageDirectory().getAbsolutePath(); String targetPath = ExternalStorageDirectoryPath + PHOTO_DIR; File targetDirector = new File(targetPath); File[] files = targetDirector.listFiles(); for (File file : files) { myImageAdapter.add(file.getAbsolutePath()); gridview.setFocusable(false); } } } else { Log.w(TAG, "Unknown Activity Result from mediaImport: " + resultCode); } } }
// This is what gets called on finishing a media piece to import @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == NEW_PICTURE) { // return from file upload if (resultCode == Activity.RESULT_OK) { Uri uri = null; if (data != null) { uri = data.getData(); } if (uri == null && mCameraFileName != null) { uri = Uri.fromFile(new File(mCameraFileName)); } File file = new File(mCameraFileName); if (uri != null) { UploadPicture upload = new UploadPicture(this, mApi, PHOTO_DIR, file); upload.execute(); } } else { Log.w(TAG, "Unknown Activity Result from mediaImport: " + resultCode); } } }