@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);
 }
Esempio n. 2
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) {
      case REQUEST_CODE:
        if (resultCode == RESULT_OK) {
          if (data != null) {
            final Uri uri = data.getData();

            try {
              final File file = FileUtils.getFile(uri);
              path = file.getAbsolutePath();
              preferences.setPath(path);
              updatePathButton();
            } catch (Exception e) {
              Log.e("FileSelectorTestActivity", "File select error", e);
            }
          }
        }
        break;
      case 1:
        if (resultCode == RESULT_OK) {
          result = data.getStringExtra("result");
          updateResultTextView();
        }
        break;
    }
    super.onActivityResult(requestCode, resultCode, data);
  }
Esempio n. 3
0
  public void launchAddFile() {
    // Launch file selection intent (includes AFileChooser's custom file chooser implementation)

    Intent intent =
        Intent.createChooser(
            FileUtils.createGetContentIntent(), getResources().getString(R.string.select_file));
    startActivityForResult(intent, REQUEST_CHOOSER);
  }
 public void selectUploadFile(View view) {
   Intent target = FileUtils.createGetContentIntent();
   Intent intent = Intent.createChooser(target, this.getString(R.string.choose_file));
   try {
     this.startActivityForResult(intent, REQUEST_CODE);
   } catch (ActivityNotFoundException ex) {
   }
 }
Esempio n. 5
0
 public void showChooser(View view) {
   Intent target = FileUtils.createGetHtmlContentIntent();
   Intent intent = Intent.createChooser(target, getString(R.string.choose_program));
   try {
     startActivityForResult(intent, REQUEST_CODE);
   } catch (ActivityNotFoundException e) {
     e.printStackTrace();
   }
 }
Esempio n. 6
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;
    }
  }