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:studio.imedia.vehicleinspection.fragments.CarInfoFragment.java

/**
 * 4.4//from   w  w  w.  ja  v a2s.  co m
 */
private void selectBeforeKitkat() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("image/*");
    startActivityForResult(intent, REQUEST_GALLERY_BEFORE_KITKAT);
}

From source file:no.nordicsemi.android.nrftoolbox.dfu.DfuActivity.java

/**
 * Called when Select File was pressed//from w  ww . java 2 s.c  o  m
 * 
 * @param view
 *            a button that was pressed
 */
public void onSelectFileClicked(final View view) {
    final Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("application/octet-stream");
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    if (intent.resolveActivity(getPackageManager()) != null) {
        // file browser has been found on the device
        startActivityForResult(intent, SELECT_FILE_REQ);
    } else {
        // there is no any file browser app, let's try to download one
        final View customView = getLayoutInflater().inflate(R.layout.app_file_browser, null);
        final ListView appsList = (ListView) customView.findViewById(android.R.id.list);
        appsList.setAdapter(new FileBrowserAppsAdapter(this));
        appsList.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
        appsList.setItemChecked(0, true);
        new AlertDialog.Builder(this).setTitle(R.string.dfu_alert_no_filebrowser_title).setView(customView)
                .setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        dialog.dismiss();
                    }
                }).setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(final DialogInterface dialog, final int which) {
                        final int pos = appsList.getCheckedItemPosition();
                        if (pos >= 0) {
                            final String query = getResources()
                                    .getStringArray(R.array.dfu_app_file_browser_action)[pos];
                            final Intent storeIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(query));
                            startActivity(storeIntent);
                        }
                    }
                }).show();
    }
}

From source file:com.danvelazco.fbwrapper.activity.BaseFacebookWebViewActivity.java

/**
 * {@inheritDoc}//  w  w w  . j  a v a  2s. co  m
 */
@Override
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
    Logger.d(LOG_TAG, "openFileChooser()");
    mUploadMessage = uploadMsg;
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("image/*");
    startActivityForResult(Intent.createChooser(i, getString(R.string.upload_file_choose)),
            RESULT_CODE_FILE_UPLOAD);
}

From source file:com.lewa.crazychapter11.MainActivity.java

private void LookupContact() {
    Button btnLookupContact = (Button) findViewById(R.id.btn_lookup_contact);
    btnLookupContact.setOnClickListener(new OnClickListener() {
        @Override//  w  w  w  . java 2  s.  co  m
        public void onClick(View v) {
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_GET_CONTENT);
            intent.setType("vnd.android.cursor.item/phone");
            startActivityForResult(intent, PICK_CONTACT);
        }
    });
    ((EditText) findViewById(R.id.show)).setVisibility(View.GONE);
    ((EditText) findViewById(R.id.phone)).setVisibility(View.GONE);
    btnLookupContact.setVisibility(View.GONE);
}

From source file:com.grass.caishi.cc.activity.AdAddActivity.java

/**
 * ?//  w  w w .  j av  a 2  s. c  om
 */
public void selectPicFromLocal() {
    Intent intent;
    if (Build.VERSION.SDK_INT < 19) {
        intent = new Intent(Intent.ACTION_GET_CONTENT);
        intent.setType("image/*");
    } else {
        intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    }
    startActivityForResult(intent, REQUEST_CODE_IMAGES);
}

From source file:com.dvn.vindecoder.ui.user.GetAllVehicalDetails.java

private void startDilog() {
    AlertDialog.Builder myAlertDilog = new AlertDialog.Builder(GetAllVehicalDetails.this);
    myAlertDilog.setTitle("Upload picture option..");
    myAlertDilog.setMessage("Take Photo");
    myAlertDilog.setPositiveButton("Gallery", new DialogInterface.OnClickListener() {
        @Override//from   ww  w  . j a  v  a  2s.  co m
        public void onClick(DialogInterface dialog, int which) {
            Intent picIntent = new Intent(Intent.ACTION_GET_CONTENT, null);
            picIntent.setType("image/*");
            picIntent.putExtra("return_data", true);
            startActivityForResult(picIntent, GALLERY_REQUEST);
        }
    });
    myAlertDilog.setNegativeButton("Camera", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                if (checkPermission(Manifest.permission.CAMERA, GetAllVehicalDetails.this)) {
                    openCameraApplication();
                } else {
                    requestPermission(GetAllVehicalDetails.this, new String[] { Manifest.permission.CAMERA },
                            REQUEST_ACESS_CAMERA);
                }
            } else {
                openCameraApplication();
            }
        }
    });
    myAlertDilog.show();
}

From source file:com.afwsamples.testdpc.SetupManagementFragment.java

private Intent getGetContentIntent() {
    Intent getContent = new Intent(Intent.ACTION_GET_CONTENT);
    getContent.setType("image/*");
    return getContent;
}

From source file:com.sumatone.cloud.securecloud.Fragments.UploadFragment.java

private void chooseFile() {
    Intent intent = new Intent();

    intent.setType("*/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent, "Complete action using"), 0);

}

From source file:com.wikitude.virtualhome.AugmentedActivity.java

public void setBkgImage() {
    Intent intent = new Intent();
    intent.setType("image/*");
    intent.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE);
}

From source file:hku.fyp14017.blencode.ui.fragment.SoundFragment.java

@Override
public void handleAddButton() {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.setType("audio/*");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        disableGoogleDrive(intent);//from   w  w  w .jav a  2s.c  om
    }
    startActivityForResult(
            Intent.createChooser(intent, getString(hku.fyp14017.blencode.R.string.sound_select_source)),
            SoundController.REQUEST_SELECT_MUSIC);
}