@Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   switch (requestCode) {
     case REQUEST_CODE:
       // If the file selection was successful
       if (resultCode == RESULT_OK) {
         if (data != null) {
           // Get the URI of the selected file
           final Uri uri = data.getData();
           try {
             // Get the file path from the URI
             final String path = FileUtils.getPath(this, uri);
             this.uploadFilePath = path;
             this.clearLog();
             this.writeLog(context.getString(R.string.qiniu_select_upload_file) + path);
           } catch (Exception e) {
             Toast.makeText(
                     context,
                     context.getString(R.string.qiniu_get_upload_file_failed),
                     Toast.LENGTH_LONG)
                 .show();
           }
         }
       }
       break;
   }
   super.onActivityResult(requestCode, resultCode, data);
 }
Пример #2
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
      case REQUEST_CHOOSER:
        if (resultCode == RESULT_OK) {
          final Uri uri = data.getData();

          // Get the File path from the Uri
          String path = FileUtils.getPath(this, uri);

          if (path != null && FileUtils.isLocal(path)) {
            File file = new File(path);
            if (file.exists()) {
              addFile(file);
            }
          }
        }

        break;
      case REQUEST_ICON_FILE:
        if (resultCode == RESULT_OK) {
          final Uri uri = data.getData();

          // Get the File path from the Uri
          String path = FileUtils.getPath(this, uri);

          if (path != null && FileUtils.isLocal(path)) {
            File file = new File(path);
            if (file.exists() && iconFile != null) {
              iconFile.setText(path);
            }
          }
        }

        break;
    }
  }