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:nu.yona.app.ui.YonaActivity.java

/**
 * Open contact book.//from  w w  w .ja  v  a 2 s  . com
 */
public void openContactBook() {
    Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
    startActivityForResult(intent, PICK_CONTACT);
}

From source file:com.ibuildapp.romanblack.FanWallPlugin.FanWallPlugin.java

public void onClick(View arg0) {
    int id = arg0.getId();

    if (id == R.id.romanblack_fanwall_main_voice) {// AddMessage pictogram in home screen

        if (Utils.networkAvailable(FanWallPlugin.this)) {
            if (!Authorization.isAuthorized()) {
                actionIntent = new Intent(this, SendMessageActivity.class);
                actionIntent.putExtra("Widget", widget);

                action = ACTIONS.SEND_MESSAGE;

                Intent it = new Intent(this, AuthorizationActivity.class);
                it.putExtra("Widget", widget);
                startActivityForResult(it, AUTHORIZATION_ACTIVITY);
            } else {
                Intent it = new Intent(this, SendMessageActivity.class);
                it.putExtra("Widget", widget);
                startActivityForResult(it, SEND_MESSAGE_ACTIVITY);
            }/*from  w  ww  . ja  va  2 s .com*/
        } else {
            handler.sendEmptyMessage(NEED_INTERNET_CONNECTION);
        }
    } else if (id == R.id.romanblack_fanwall_tab_map_layout) {

        Intent bridge = new Intent(FanWallPlugin.this, FanWallMapActivity.class);
        bridge.putExtra("messages", messages);
        startActivityForResult(bridge, SHOW_MAP_ACTIVITY);

    } else if (id == R.id.romanblack_fanwall_tab_photos_layout) {

        Intent bridge = new Intent(FanWallPlugin.this, FanWallPhotoListActivity.class);
        bridge.putExtra("widget", widget);
        startActivityForResult(bridge, SHOW_PHOTOLIST_ACTIVITY);
    } else if (id == R.id.romanblack_fanwall_send_post) {
        if (TextUtils.isEmpty(editMsg.getText()) && TextUtils.isEmpty(imagePath))
            return;

        if (Utils.networkAvailable(FanWallPlugin.this)) {
            if (!Authorization.isAuthorized()) {
                action = ACTIONS.SEND_MESSAGE_FROM_WALL;
                Intent it = new Intent(FanWallPlugin.this, AuthorizationActivity.class);
                it.putExtra("Widget", widget);
                startActivityForResult(it, AUTHORIZATION_ACTIVITY);
            } else {
                showProgressDialog();
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        FanWallMessage msg = Statics.postMessage(editMsg.getText().toString(), imagePath, 0, 0,
                                Prefs.with(getApplicationContext()).getBoolean(Prefs.KEY_GPS, false));
                        if (msg != null) {
                            handler.sendEmptyMessage(CLEAR_MSG_TEXT);

                            if (messages.size() == 0)
                                refreshMessages();
                            else
                                refreshTop();
                        }
                        handler.sendEmptyMessage(HIDE_PROGRESS_DIALOG);
                    }
                }).start();
            }
        } else {
            handler.sendEmptyMessage(NEED_INTERNET_CONNECTION);
        }
    } else if (id == R.id.fanwall_close_image) {
        imageHolder.setVisibility(View.GONE);
        imagePath = "";
    } else if (id == R.id.romanblack_fanwall_open_bottom) {
        if (chooserHolder.getVisibility() == View.GONE)
            chooserHolder.setVisibility(View.VISIBLE);
        else if (chooserHolder.getVisibility() == View.VISIBLE)
            chooserHolder.setVisibility(View.GONE);
    } else if (id == R.id.romanblack_fanwall_gallery) {
        Intent i = new Intent(Intent.ACTION_PICK,
                android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        startActivityForResult(i, PICK_IMAGE_ACTIVITY);
    } else if (id == R.id.romanblack_fanwall_make_photo) {
        /*if (android.os.Build.VERSION.SDK_INT >= 23) {
        int res = ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
        if (res != PackageManager.PERMISSION_GRANTED){
            Toast.makeText(this,R.string.fanwall_no_camera_permision, Toast.LENGTH_LONG).show();
            return;
        }
        }*/
        Intent it = new Intent(FanWallPlugin.this, CameraActivity.class);
        it.putExtra("Widget", widget);
        startActivityForResult(it, TAKE_A_PICTURE_ACTIVITY);
    }
}

From source file:org.getlantern.firetweet.activity.support.ComposeActivity.java

private boolean pickImage() {
    final Intent intent = new Intent(Intent.ACTION_PICK);
    intent.setType("image/*");
    intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    try {//from   w ww.  j  a va2  s.co  m
        startActivityForResult(intent, REQUEST_PICK_IMAGE);
    } catch (final ActivityNotFoundException e) {
        showErrorMessage(this, null, e, false);
        return false;
    }
    return true;
}

From source file:org.kontalk.ui.ComposeMessageFragment.java

/** Starts activity for a vCard attachment from a contact. */
private void selectContactAttachment() {
    Intent i = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
    startActivityForResult(i, SELECT_ATTACHMENT_CONTACT);
}

From source file:com.dwdesign.tweetings.fragment.UserProfileFragment.java

private void pickImage() {
    final Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*");
    startActivityForResult(intent, REQUEST_PICK_IMAGE);
}

From source file:com.dwdesign.tweetings.fragment.UserProfileFragment.java

private void pickBannerImage() {
    final Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*");
    startActivityForResult(intent, REQUEST_BANNER_PICK_IMAGE);
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static Intent createPickImageIntent(final Uri uri) {
    final Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*");
    return intent;
}

From source file:com.chaqianma.jd.fragment.CompanyInfoFragment.java

@Override
public void onChoosePhoto() {
    Intent intent = new Intent(Intent.ACTION_PICK);
    intent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
    startActivityForResult(intent, REQUEST_SDK_IMGS);
}

From source file:de.vanita5.twittnuker.util.Utils.java

public static Intent createPickImageIntent(final Uri uri, final Integer outputX, final Integer outputY,
        final Integer aspectX, final Integer aspectY, final boolean scaleUpIfNeeded) {
    final Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*");
    if (outputX != null && outputY != null) {
        intent.putExtra(CameraCropActivity.EXTRA_OUTPUT_X, outputX);
        intent.putExtra(CameraCropActivity.EXTRA_OUTPUT_Y, outputY);
    }//from w w  w.j  av  a 2  s .c o m
    if (aspectX != null && aspectY != null) {
        intent.putExtra(CameraCropActivity.EXTRA_ASPECT_X, aspectX);
        intent.putExtra(CameraCropActivity.EXTRA_ASPECT_Y, aspectY);
    }
    intent.putExtra("scale", true);
    intent.putExtra("scaleUpIfNeeded", scaleUpIfNeeded);
    intent.putExtra("crop", "true");
    intent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
    return intent;
}

From source file:nu.yona.app.ui.YonaActivity.java

private void pickImage() {
    Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
    intent.setType("image/*");
    startActivityForResult(intent, PICK_IMAGE);
    skipVerification = true;/*  w ww.  java  2 s .co  m*/
}