Example usage for android.content Intent ACTION_GET_CONTENT

List of usage examples for android.content Intent ACTION_GET_CONTENT

Introduction

In this page you can find the example usage for android.content Intent ACTION_GET_CONTENT.

Prototype

String ACTION_GET_CONTENT

To view the source code for android.content Intent ACTION_GET_CONTENT.

Click Source Link

Document

Activity Action: Allow the user to select a particular kind of data and return it.

Usage

From source file:com.luorrak.ouroboros.reply.ReplyCommentFragment.java

private void selectFile() {
    boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
    if (isKitKat) {
        Intent intent = new Intent();
        intent.setType("*/*");
        intent.setAction(Intent.ACTION_GET_CONTENT);
        startActivityForResult(intent, FILE_SELECT_CODE);

    } else {/* ww  w.  j  a  va  2  s  .  c  om*/
        Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("*/*");
        startActivityForResult(intent, FILE_SELECT_CODE);
    }
}

From source file:com.fvd.nimbus.MainActivity.java

public void onButtonClick(View v) {
    switch (v.getId()) {
    case R.id.bTakePhoto:
        showProgress(true);//from w w  w  . j  a v  a 2  s  . com
        getPhoto();
        break;
    case R.id.bFromGallery:
        try {
            showProgress(true);
            Intent fileChooserIntent = new Intent();
            fileChooserIntent.addCategory(Intent.CATEGORY_OPENABLE);
            fileChooserIntent.setType("image/*");
            fileChooserIntent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(fileChooserIntent, "Select Picture"), TAKE_PICTURE);
        } catch (Exception e) {
            appSettings.appendLog("main:onClick  " + e.getMessage());
            showProgress(false);
        }
        break;
    case R.id.bWebClipper:
        Intent iBrowse = new Intent();
        iBrowse.setClassName("com.fvd.nimbus", "com.fvd.nimbus.BrowseActivity");
        startActivity(iBrowse);
        //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
        overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
        break;
    case R.id.bPdfAnnotate:
        Intent ip = new Intent();
        ip.setClassName("com.fvd.nimbus", "com.fvd.nimbus.ChoosePDFActivity");
        startActivity(ip);
        //overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
        overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
        break;
    case R.id.ibSettings:
        Intent inten = new Intent(getApplicationContext(), SettingsActivity.class);
        startActivityForResult(inten, SHOW_SETTINGS);
        //overridePendingTransition(R.anim.carbon_slide_in,R.anim.carbon_slide_out);
        overridePendingTransition(R.anim.carbon_slide_in, R.anim.carbon_slide_out);
        break;
    /*case R.id.bssSettings:
       Intent i = new Intent(getApplicationContext(), PrefsActivity.class);
        startActivity(i);
        overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
       break;
    case R.id.bssRegister:
       Intent intent = new Intent(getApplicationContext(), RegisterDlg.class);
       intent.putExtra("userMail", userMail==null?"":userMail);
       startActivityForResult(intent, 5);
       overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
       break;   
    case R.id.bssHelp:
       Uri uri = Uri.parse("http://help.everhelper.me/customer/portal/articles/1376820-nimbus-clipper-for-android---quick-guide");
       Intent it = new Intent(Intent.ACTION_VIEW, uri);
       startActivity(it);
       overridePendingTransition( R.anim.slide_in_up, R.anim.slide_out_up );
       break;
    case R.id.bssLogin:
       if(serverHelper.getInstance().getSession().length() == 0) showLogin();
       else {
     String sessionId="";
     serverHelper.getInstance().setSessionId(sessionId);
     appSettings.storeUserData(this, userMail, "", "");
     Editor e = prefs.edit();
     e.putString("userMail", userMail);
       e.putString("userPass", "");
       e.putString("sessionId", sessionId);
       e.commit();
     showLogin();
     }
       break;
    case R.id.bssRateUs:
       try{
       startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + getApplicationInfo().packageName)));
    }
    catch(Exception e){
    }
       break;*/
    }
}

From source file:com.android.talkback.labeling.LabelManagerSummaryActivity.java

private void addImportCustomLabelClickListener() {
    final Button importLabel = (Button) findViewById(R.id.import_labels);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
        importLabel.setVisibility(View.GONE);
        return;//from   w w  w  .  j  a v a2 s . c  o  m
    }
    importLabel.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent importIntent = new Intent();
            importIntent.setAction(Intent.ACTION_GET_CONTENT);
            importIntent.setType("application/json");
            importIntent.addCategory(Intent.CATEGORY_OPENABLE);
            startActivityForResult(importIntent, SELECT_LABEL_FILE_REQUEST);
        }
    });
}

From source file:de.bahnhoefe.deutschlands.bahnhofsfotos.DetailsActivity.java

public void selectPicture() {
    if (!canSetPhoto()) {
        return;/*w ww. j a  va 2  s  .co m*/
    }

    if (isMyDataIncomplete()) {
        checkMyData();
    } else {
        File file = getCameraMediaFile();
        if (file != null) {
            Intent intent = new Intent();
            intent.setType("image/*");
            intent.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(intent, getString(R.string.select_picture)),
                    REQUEST_SELECT_PICTURE);
        } else {
            Toast.makeText(this, R.string.unable_to_create_folder_structure, Toast.LENGTH_LONG).show();
        }
    }
}

From source file:de.kodejak.hashr.fragmentHashFromFile.java

public void OnButtonGetHashFromFileClick() {
    Intent chooseFile;//from w  ww  .  j  a  v a 2 s . c  o  m
    Intent intent;
    chooseFile = new Intent(Intent.ACTION_GET_CONTENT);
    chooseFile.setType("file/*");
    intent = Intent.createChooser(chooseFile, "Choose a " + fragJobExt + " file");
    fileJob = 1; // open to generate
    getActivity().startActivityForResult(intent, ACTIVITY_CHOOSE_FILE);
}

From source file:com.android.messaging.ui.UIIntentsImpl.java

@Override
public void launchDocumentImagePicker(final Fragment fragment) {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.putExtra(Intent.EXTRA_MIME_TYPES, MessagePartData.ACCEPTABLE_IMAGE_TYPES);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType(ContentType.IMAGE_UNSPECIFIED);

    fragment.startActivityForResult(intent, REQUEST_PICK_IMAGE_FROM_DOCUMENT_PICKER);
}

From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java

private void buildDefaultState() {
    mState = new State();

    final Intent intent = virtualIntent;
    final String action = intent.getAction();
    if (Intent.ACTION_OPEN_DOCUMENT.equals(action)) {
        mState.action = ACTION_OPEN;/*from www. j  a v a2s.co m*/
    } else if (Intent.ACTION_CREATE_DOCUMENT.equals(action)) {
        mState.action = ACTION_CREATE;
    } else if (Intent.ACTION_GET_CONTENT.equals(action)) {
        mState.action = ACTION_GET_CONTENT;
    } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) {
        mState.action = ACTION_MANAGE;
    }

    if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) {
        mState.allowMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false);
    }

    if (mState.action == ACTION_MANAGE) {
        mState.acceptMimes = new String[] { "*/*" };
        mState.allowMultiple = true;
    } else if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) {
        mState.acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES);
    } else {
        mState.acceptMimes = new String[] { intent.getType() };
    }

    mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false);
    mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false);
    mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this);
}

From source file:com.stoyanr.feeder.activity.ChannelsActivity.java

private boolean shouldSetResult(String action) {
    return action.equals(Intent.ACTION_PICK) || action.equals(Intent.ACTION_GET_CONTENT);
}

From source file:com.z299studio.pb.ActionDialog.java

private void showFileChooser() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("*/*");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    try {/*from  w  w  w.  j a v  a2  s  .co m*/
        getActivity().startActivityForResult(
                Intent.createChooser(intent, getResources().getString(R.string.select_file)),
                REQ_CODE_FILE_SELECTION);
    } catch (android.content.ActivityNotFoundException ex) {
        Application.showToast(getActivity(), R.string.no_file_explorer, Toast.LENGTH_SHORT);
    }
}

From source file:com.cerema.cloud2.ui.fragment.OCFileListFragment.java

/**
 * registers {@link android.view.View.OnClickListener} and {@link android.view.View.OnLongClickListener}
 * on the Upload from App mini FAB for the linked action and {@link Toast} showing the underlying action.
 *///ww w  .ja v a2  s  . c om
private void registerFabUploadFromAppListeners() {
    getFabUploadFromApp().setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent action = new Intent(Intent.ACTION_GET_CONTENT);
            action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE);
            //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
                action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
            }
            getActivity().startActivityForResult(
                    Intent.createChooser(action, getString(R.string.upload_chooser_title)),
                    FileDisplayActivity.ACTION_SELECT_CONTENT_FROM_APPS);
            getFabMain().collapse();
            recordMiniFabClick();
        }
    });

    getFabUploadFromApp().setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Toast.makeText(getActivity(), R.string.actionbar_upload_from_apps, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
}