Example usage for android.content Intent ACTION_PICK

List of usage examples for android.content Intent ACTION_PICK

Introduction

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

Prototype

String ACTION_PICK

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

Click Source Link

Document

Activity Action: Pick an item from the data, returning what was selected.

Usage

From source file:com.example.multi_ndef.frag_mail.java

@Override
public void onClick(View v) {
    // TODO Auto-generated method stub

    if (((Button) v).getId() == fetchto.getId()) {
        Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
        startActivityForResult(intent, PICK_MAIL);
        Control = "To";

    }/*from   w  w w .  java  2 s.  co  m*/

    else if (((Button) v).getId() == fetchcc.getId()) {
        Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
        startActivityForResult(intent, PICK_MAIL);
        Control = "Cc";

    }

    else if (((Button) v).getId() == fetchbcc.getId()) {
        Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
        startActivityForResult(intent, PICK_MAIL);
        Control = "Bcc";

    }

}

From source file:com.cloudbase.cbhelperdemo.DataScreen.java

@Override
public void onClick(View v) {
    if (v.getId() == R.id.insertButton) {
        TestDataObject obj = this.createObject();
        // use the shared object and send an insert to the basic data object
        MainActivity.helper.insertDocument(obj, "android_demo_collection", true);
    }//from w ww  .  j a  v a  2 s . c  o m

    if (v.getId() == R.id.insertFileButton) {
        // create a photopicker to attach a file. the insert completes in the onActivityResult
        Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
        photoPickerIntent.setType("image/*");
        startActivityForResult(photoPickerIntent, 1);
    }

    if (v.getId() == R.id.searchButton) {
        // run a search over the test collection for all the objects with firstName of "cloud". Should be all of them.
        // this Fragment is also the responder
        CBSearchCondition cond = new CBSearchCondition("firstName", CBSearchConditionOperator.CBOperatorEqual,
                "cloud");
        cond.addSortField("firstName", -1);
        cond.setLimit(1);

        /*
        List<CBDataAggregationCommand> aggregationCommands = new ArrayList<CBDataAggregationCommand>();
                
        CBDataAggregationCommandProject projectCommand = new CBDataAggregationCommandProject();
        projectCommand.getIncludeFields().add("Symbol");
        projectCommand.getIncludeFields().add("Price");
        projectCommand.getIncludeFields().add("total");
        aggregationCommands.add(projectCommand);
                
        CBDataAggregationCommandGroup groupCommand = new CBDataAggregationCommandGroup();
        groupCommand.addOutputField("Symbol");
        groupCommand.addGroupFormulaForField("total", CBDataAggregationGroupOperator.CBDataAggregationGroupSum, "Price");
        aggregationCommands.add(groupCommand);
        */
        MainActivity.helper.searchDocument("android_demo_collection", cond, this);
        //MainActivity.helper.searchDocumentAggregate("security_master_3", aggregationCommands, this);

    }

    if (v.getId() == R.id.downloadButton) {
        TextView fileIdText = (TextView) this.getView().findViewById(R.id.fileIdText);
        String fileId = fileIdText.getText().toString();

        // download file and show the image in a popup view - This Fragment is also the responder
        MainActivity.helper.downloadFile(fileId, this);
    }
}

From source file:pl.zajecia.cw3.PhotosActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_photos);

    /** Load photos from shared preferences 
     * and parse it to List*///w ww .  j  a  v a  2  s . co  m
    mPhotos = new ArrayList<String>();
    SharedPreferences settings = getSharedPreferences(MainActivity.PREFERENCES, 0);
    String paths = settings.getString(MainActivity.FILE_PATHS, "");
    String[] pathsArray = paths.split(";");
    for (String p : pathsArray) {
        if (p != "") {
            mPhotos.add(p);
        }
    }

    /** Show the Up button in the action bar. */
    getActionBar().setDisplayHomeAsUpEnabled(true);

    /** Register onClickListener for displaying gallery activity */
    Button addImageButton = (Button) findViewById(R.id.addImageFromGallery);
    addImageButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            startActivityForResult(i, RESULT_LOAD_IMAGE);
        }
    });

    /**Set up GridView gallery */
    mPhotosAdapter = new PhotosAdapter(this);
    mPhotosGridView = (GridView) findViewById(R.id.photosGridView);
    mPhotosGridView.setAdapter(mPhotosAdapter);

    /** set up context menu for gallery gridView */
    registerForContextMenu(mPhotosGridView);
}

From source file:com.allen.mediautil.ImageTakerHelper.java

/**
 * ? onActivityResult()?//w w w .  ja  va2s  . com
 */
public static void openAlbum(Fragment fragment) {
    Intent intentAlbum = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intentAlbum.setType(MEDIA_TYPE_IMAGE);
    fragment.startActivityForResult(Intent.createChooser(intentAlbum, ""), REQUEST_ALBUM);
}

From source file:com.mvc.imagepicker.ImagePicker.java

/**
 * Get an Intent which will launch a dialog to pick an image from camera/gallery apps.
 *
 * @param context      context./*from w  w w. j ava 2 s  .co  m*/
 * @param chooserTitle will appear on the picker dialog.
 * @return intent launcher.
 */
public static Intent getPickImageIntent(Context context, String chooserTitle) {
    Intent chooserIntent = null;
    List<Intent> intentList = new ArrayList<>();

    Intent pickIntent = new Intent(Intent.ACTION_PICK,
            android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intentList = addIntentsToList(context, intentList, pickIntent);

    // Camera action will fail if the app does not have permission, check before adding intent.
    // We only need to add the camera intent if the app does not use the CAMERA permission
    // in the androidmanifest.xml
    // Or if the user has granted access to the camera.
    // See https://developer.android.com/reference/android/provider/MediaStore.html#ACTION_IMAGE_CAPTURE
    if (!appManifestContainsPermission(context, Manifest.permission.CAMERA) || hasCameraAccess(context)) {
        Intent takePhotoIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        takePhotoIntent.putExtra("return-data", true);
        takePhotoIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(getTemporalFile(context)));
        intentList = addIntentsToList(context, intentList, takePhotoIntent);
    }

    if (intentList.size() > 0) {
        chooserIntent = Intent.createChooser(intentList.remove(intentList.size() - 1), chooserTitle);
        chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,
                intentList.toArray(new Parcelable[intentList.size()]));
    }

    return chooserIntent;
}

From source file:com.example.cake.mqtttest.registerActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_register);

    Button bt_regis = (Button) findViewById(R.id.bt_cancel);
    bt_regis.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w ww  . j  a  va2  s.  co m*/
        public void onClick(View view) {

            Intent i_regis = new Intent(getApplicationContext(), MainActivity.class);
            startActivity(i_regis);
        }
    });

    TextView cImage = (TextView) findViewById(R.id.choose_image_from);
    cImage.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
            photoPickerIntent.setType("image/*");
            startActivityForResult(photoPickerIntent, SELECT_PHOTO);
        }
    });

    Eid = (EditText) findViewById(R.id.edit_id);
    EfirstName = (EditText) findViewById(R.id.edit_first_name);
    ElastName = (EditText) findViewById(R.id.edit_lastname);
    Eemail = (EditText) findViewById(R.id.edit_email);
    EphoneNumber = (EditText) findViewById(R.id.edit_mobile_number);
    Epassword = (EditText) findViewById(R.id.edit_pass);
    // EidNumber = (EditText) findViewById(R.id.edit_id);
    EcarModel = (EditText) findViewById(R.id.edit_car_model);
    ElicensePlateNumber = (EditText) findViewById(R.id.edit_license_plate);

    Button bt_reg = (Button) findViewById(R.id.bt_regis);
    bt_reg.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {

            String[] ll = new String[9];
            ll[0] = "id" + Eid.getText().toString();
            ll[1] = EfirstName.getText().toString();
            ll[2] = ElastName.getText().toString();
            ll[3] = Eemail.getText().toString();
            ll[4] = EphoneNumber.getText().toString();
            ll[5] = Epassword.getText().toString();
            ll[6] = Eid.getText().toString();
            ll[7] = EcarModel.getText().toString();
            ll[8] = ElicensePlateNumber.getText().toString();

            if (!ll[0].isEmpty() && !ll[1].isEmpty() && !ll[2].isEmpty() && !ll[3].isEmpty() && !ll[4].isEmpty()
                    && !ll[5].isEmpty() && !ll[6].isEmpty() && !ll[7].isEmpty() && !ll[8].isEmpty()) {
                sendRegisterRequest loginRequest = new sendRegisterRequest();
                loginRequest.delegate = registerActivity.this;
                loginRequest.execute(ll);

                String filename = Eid.getText().toString() + ".png";
                String[] lll = { filename, encoded };
                sendImageRequest imRequest = new sendImageRequest();
                imRequest.delegate = registerActivity.this;
                imRequest.execute(lll);

            } else {
                new AlertDialog.Builder(registerActivity.this).setCancelable(false).setTitle("Incomplete data")
                        .setMessage("Please fill all the fields.")
                        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            }
                        }).show();

            }

        }
    });

}

From source file:net.wespot.pim.utils.layout.CaptureImageDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    // Get the layout inflater
    LayoutInflater inflater = getActivity().getLayoutInflater();

    builder.setTitle(R.string.data_collection_dialog_choose_action).setItems(R.array.capturing_picture,
            new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    switch (which) {
                    case 0:
                        pictureManager.setRunId(INQ.inquiry.getCurrentInquiry().getRunId());
                        pictureManager.setGeneralItem(generalItemLocalObject);
                        pictureManager.takeDataSample(null);
                        break;
                    case 1:
                        Intent cameraIntent = new Intent(Intent.ACTION_PICK,
                                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
                        bitmapFile = MediaFolders.createOutgoingJpgFile();
                        cameraIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT,
                                Uri.fromFile(bitmapFile));
                        startActivityForResult(cameraIntent, PICTURE_RESULT);
                        break;
                    }//from  w  w  w  .  j av  a  2 s  .  c o m
                }
            });
    return builder.create();
}

From source file:com.stj.fileexplorer.FileExplorerTabActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    // add begin by xugaoming@20140317, don't need to restore
    // fragments automaticaly if killed by system for memory,
    // it will mess up the logic
    savedInstanceState = null;//from w  w w .ja va  2 s .  c  o  m
    // add end

    super.onCreate(savedInstanceState);
    StorageHelper.getInstance(this);
    setContentView(R.layout.fragment_pager);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setOffscreenPageLimit(DEFAULT_OFFSCREEN_PAGES);

    final ActionBar bar = getActionBar();
    bar.hide();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    //        mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_category),
    //                FileCategoryActivity.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_sd), FileViewActivity.class, null);

    FileViewActivity fileViewActivity = ((FileViewActivity) getFragment(Util.SDCARD_TAB_INDEX));
    fileViewActivity.registBottomBtnPressListener(this);

    /*mTabsAdapter.addTab(bar.newTab().setText(R.string.tab_remote),
        ServerControlActivity.class, null);*/
    int selectedItem = PreferenceManager.getDefaultSharedPreferences(this).getInt(INSTANCESTATE_TAB,
            Util.CATEGORY_TAB_INDEX);
    if (Intent.ACTION_PICK.equals(getIntent().getAction())) {
        selectedItem = Util.SDCARD_TAB_INDEX;
    }
    //add begin by xugaoming@20140517, add function to locate
    //to a directory
    Intent intent = getIntent();
    if (intent != null && intent.getStringExtra("goto_dir") != null) {
        selectedItem = Util.SDCARD_TAB_INDEX;
    }
    //add end
    bar.setSelectedNavigationItem(0);
}

From source file:com.examples.abelanav2.ui.UploadFragment.java

/**
 * Starts the select photo intent.// www  .  j a  v a2  s.co m
 */
private void selectPhoto() {
    Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
    photoPickerIntent.setType("image/*");
    startActivityForResult(photoPickerIntent, SELECT_PHOTO_INTENT);
}

From source file:com.example.multi_ndef.frag_sms.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.frag_sms, container, false);

    fetchContact = (Button) v.findViewById(R.id.fetchContact);
    numbers = (EditText) v.findViewById(R.id.editcontact);
    Recipients = (TextView) v.findViewById(R.id.Recipients);
    addMore = (Button) v.findViewById(R.id.addRec);
    addMore.setOnClickListener(this);
    ma = (CNFCInterface) getActivity().getApplication();

    fetchContact.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {

            if (!numbers.getText().toString().isEmpty()) {
                if (noOfContacts == 1) {
                    MultiContacts = numbers.getText().toString();
                    noOfContacts++;//from   w w w .  j  a  va 2s  .  c om
                    numbers.setText("");
                    recipients = MultiContacts;
                    Recipients.setText(recipients);
                    ma.setMultiContacts(MultiContacts);
                    ma.setnoOfContacts(noOfContacts);

                } else {
                    MultiContacts += ";" + numbers.getText().toString();
                    noOfContacts++;
                    numbers.setText("");
                    recipients = MultiContacts;
                    Recipients.setText(recipients);
                    ma.setMultiContacts(MultiContacts);
                    ma.setnoOfContacts(noOfContacts);

                }
            }

            Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
            startActivityForResult(intent, PICK_NUMBER);

        }
    });

    return v;
}