List of usage examples for android.content Intent ACTION_PICK
String ACTION_PICK
To view the source code for android.content Intent ACTION_PICK.
Click Source Link
From source file:com.alivenet.dmv.driverapplication.fragment.MyAccount.java
public static void openGallery(final Activity context) { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); context.startActivityForResult(photoPickerIntent, ConstantUtil.REQUEST_CODE_GALLERY); }
From source file:com.money.manager.ex.common.CategoryListFragment.java
private void addListClickHandlers() { // the list handlers available only when selecting a category. if (mAction.equals(Intent.ACTION_PICK)) { getExpandableListView().setOnChildClickListener(new ExpandableListView.OnChildClickListener() { @Override// w w w . jav a2 s . co m public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (getExpandableListAdapter() != null && getExpandableListAdapter() instanceof CategoryExpandableListAdapter) { CategoryExpandableListAdapter adapter = (CategoryExpandableListAdapter) getExpandableListAdapter(); QueryCategorySubCategory data = mSubCategories.get(mCategories.get(groupPosition)) .get(childPosition); adapter.setIdChildChecked(data.getCategId(), data.getSubCategId()); adapter.notifyDataSetChanged(); // select sub-categories immediately. setResultAndFinish(); } return false; } }); getExpandableListView().setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { if (getExpandableListAdapter() != null && getExpandableListAdapter() instanceof CategoryExpandableListAdapter) { CategoryExpandableListAdapter adapter = (CategoryExpandableListAdapter) getExpandableListAdapter(); Category category = mCategories.get(groupPosition); adapter.setIdGroupChecked(category.getId()); adapter.notifyDataSetChanged(); int subCategoriesCount = mSubCategories.get(category).size(); if (subCategoriesCount == 0) { setResultAndFinish(); } } return false; } }); } }
From source file:com.maskyn.fileeditorpro.activity.MainActivity.java
/** * Parses the intent/*from w w w .jav a 2 s. c om*/ */ private void parseIntent(Intent intent) { final String action = intent.getAction(); final String type = intent.getType(); if (Intent.ACTION_VIEW.equals(action) || Intent.ACTION_EDIT.equals(action) || Intent.ACTION_PICK.equals(action) && type != null) { // Post event //newFileToOpen(new File(intent // .getData().getPath()), ""); Uri uri = intent.getData(); GreatUri newUri = new GreatUri(uri, AccessStorageApi.getPath(this, uri), AccessStorageApi.getName(this, uri)); newFileToOpen(newUri, ""); } else if (Intent.ACTION_SEND.equals(action) && type != null) { if ("text/plain".equals(type)) { newFileToOpen(new GreatUri(Uri.EMPTY, "", ""), intent.getStringExtra(Intent.EXTRA_TEXT)); } } }
From source file:mobisocial.bento.ebento.ui.EditFragment.java
public void goGallery() { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_PICK); startActivityForResult(intent, REQUEST_GALLERY); }
From source file:com.stockita.stockitapointofsales.activities.MainActivity.java
/** * This callback coming from the {@link ItemMasterListFragmentUI.MyAdapter} * @param userUid The user UID//from w w w . j a va 2 s. c o m * @param pushKey The server unique key * @param model The model POJO */ @Override public void onItemMasterEditDialogCallBacks(int requestCode, String userUid, String pushKey, Object model) { switch (requestCode) { /** * This case coming from {@link ItemMasterListFragmentUI.MyAdapter} to * show {@link ItemMasterEditFormDialogFragment}, so the user can edit the item master. */ case Constants.REQUEST_CODE_DIALOG_ONE: // Instantiate the dialog fragment object and pass the encoded email, pushKey, and the itemModel as an argument ItemMasterEditFormDialogFragment itemMasterEditFormDialogFragment = ItemMasterEditFormDialogFragment .newInstance(userUid, pushKey, (ItemModel) model); // Show the Dialog Fragment on the screen itemMasterEditFormDialogFragment.show(getFragmentManager(), FRAGMENT_DIALOG_ITEM_MASTER_EDIT); break; /** * If the user choose to add image from the gallery */ case Constants.REQUEST_CODE_DIALOG_TWO: aaItemMasterUserUid = userUid; aaItemMasterPushKey = pushKey; // Check of permission if (android.support.v4.app.ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { return; } Intent i = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); // Verify that the intent will resolve to an activity */ if (i.resolveActivity(getPackageManager()) != null) { startActivityForResult(i, GET_FROM_GALLERY_REQUEST_CODE); } break; /** * If the user choose to take a photo from the camera */ case Constants.REQUEST_CODE_DIALOG_THREE: aaItemMasterUserUid = userUid; aaItemMasterPushKey = pushKey; // Check for permission if (android.support.v4.app.ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) != PackageManager.PERMISSION_GRANTED) { return; } Intent startCustomCameraIntent = new Intent(this, CameraActivity.class); startActivityForResult(startCustomCameraIntent, TAKE_PHOTO); break; } }
From source file:illab.nabal.NabalSimpleDemoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_nabal_simple_demo); CookieSyncManager.createInstance(NabalSimpleDemoActivity.this); mBackground = (RelativeLayout) findViewById(R.id.relativeLayout1); mImgBtn1 = (ImageButton) findViewById(R.id.imageButton1); mImgBtn2 = (ImageButton) findViewById(R.id.imageButton2); mImgBtn3 = (ImageButton) findViewById(R.id.imageButton3); mImgBtn4 = (ImageButton) findViewById(R.id.imageButton4); mImgBtn5 = (ImageButton) findViewById(R.id.imageButton5); mImgBtn7 = (ImageButton) findViewById(R.id.imageButton7); mImgBtn8 = (ImageButton) findViewById(R.id.imageButton8); mEditText1 = (EditText) findViewById(R.id.editText1); mEditText2 = (EditText) findViewById(R.id.editText2); mEditText3 = (EditText) findViewById(R.id.editText3); mDialogHelper.toast("Please log in first."); mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE); mInputMethodManager.hideSoftInputFromWindow(mEditText1.getWindowToken(), 0); mInputMethodManager.hideSoftInputFromWindow(mEditText2.getWindowToken(), 0); // set a listener to background for a fling mGestureDetector = new GestureDetector(this, new GestureDetector.SimpleOnGestureListener() { @Override//www . j av a 2 s .c om public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { try { if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH) { return false; } // right to left swipe if (e1.getX() - e2.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { if (mCurrentSnsId == SocialNetwork.FACEBOOK) { toggleSnsButtons(SocialNetwork.WEIBO); } else if (mCurrentSnsId == SocialNetwork.TWITTER) { toggleSnsButtons(SocialNetwork.FACEBOOK); } else if (mCurrentSnsId == SocialNetwork.WEIBO) { toggleSnsButtons(SocialNetwork.TWITTER); } } // left to right swipe else if (e2.getX() - e1.getX() > SWIPE_MIN_DISTANCE && Math.abs(velocityX) > SWIPE_THRESHOLD_VELOCITY) { if (mCurrentSnsId == SocialNetwork.FACEBOOK) { toggleSnsButtons(SocialNetwork.TWITTER); } else if (mCurrentSnsId == SocialNetwork.TWITTER) { toggleSnsButtons(SocialNetwork.WEIBO); } else if (mCurrentSnsId == SocialNetwork.WEIBO) { toggleSnsButtons(SocialNetwork.FACEBOOK); } } } catch (Exception e) { // nothing } return false; } }); View.OnTouchListener gestureListener = new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { return mGestureDetector.onTouchEvent(event); } }; mBackground.setOnTouchListener(gestureListener); // set a listener to background for a long-click mBackground.setOnLongClickListener(new OnLongClickListener() { public boolean onLongClick(View v) { Log.i(TAG, "#### background area long-clicked"); if (mCurrentSnsId == SocialNetwork.FACEBOOK) { if (mFbBgBitmap != null) { new PhotoDialog(NabalSimpleDemoActivity.this, mFbBgBitmap).show(); } } else if (mCurrentSnsId == SocialNetwork.TWITTER) { if (mTwBgBitmap != null) { new PhotoDialog(NabalSimpleDemoActivity.this, mTwBgBitmap).show(); } } else if (mCurrentSnsId == SocialNetwork.WEIBO) { if (mWeBgBitmap != null) { new PhotoDialog(NabalSimpleDemoActivity.this, mWeBgBitmap).show(); } } return false; } }); // set a listener to Facebook button mImgBtn3.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### Facebook button clicked"); toggleSnsButtons(SocialNetwork.FACEBOOK); } }); // set a listener to Twitter button mImgBtn4.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### Twitter button clicked"); toggleSnsButtons(SocialNetwork.TWITTER); } }); // set a listener to Weibo button mImgBtn5.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### Weibo button clicked"); toggleSnsButtons(SocialNetwork.WEIBO); } }); // set a listener to portrait button mImgBtn1.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### portrait button clicked"); clearOutProfileUi(); clearProfileBufferData(mCurrentSnsId); mHasErrorOccurredWhileFetchingProfile = false; mImgBtn1.setVisibility(View.GONE); requestMyProfile(); requestMyLastStatus(); } }); mImgBtn1.setOnLongClickListener(new OnLongClickListener() { public boolean onLongClick(View paramView) { //Log.i(TAG, "#### portrait button long-clicked"); confirmJumpToSnsProfile(); return true; } }); // set a listener to photo attach button mImgBtn7.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### photo attach button clicked"); // if not logged-in yet if (mOpAgent.isSessionValid(mCurrentSnsId) == false) { mEditText1.setText(""); mDialogHelper.toast("Please log in first."); } // if logged-in already else { final String message = mEditText1.getText().toString(); if (StringHelper.isEmpty(message) == true) { mDialogHelper.toast("Please enter the photo description correctly."); } else { Intent pickPhoto = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(pickPhoto, REQ_CODE_FETCH_BITMAP_FROM_GALLERY); } } } }); // set a listener to status update button mImgBtn2.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### status update button clicked"); // if not logged-in yet if (mOpAgent.isSessionValid(mCurrentSnsId) == false) { mEditText1.setText(""); mDialogHelper.toast("Please log in first."); } // if logged-in already else { final String message = mEditText1.getText().toString(); if (StringHelper.isEmpty(message) == true) { mDialogHelper.toast("Please enter your status correctly."); } else { postStatus(message); } } } }); // set a listener to link button mImgBtn8.setOnClickListener(new Button.OnClickListener() { public void onClick(View v) { //Log.i(TAG, "#### photo attach button clicked"); // if not logged-in yet if (mOpAgent.isSessionValid(mCurrentSnsId) == false) { } // if logged-in already else { confirmJumpToLinkDialog(); } } }); }
From source file:com.speedtong.example.ui.chatting.ChattingActivity.java
private void handleSelectImageIntent() { Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, REQUEST_CODE_LOAD_IMAGE); }
From source file:cn.kangeqiu.kq.activity.ChatActivity.java
/** * /*from w w w. j a v a2 s . c o m*/ */ private void selectFileFromLocal() { Intent intent = null; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); } else { intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); } startActivityForResult(intent, REQUEST_CODE_SELECT_FILE); }
From source file:org.onebusaway.android.report.ui.Open311ProblemFragment.java
private void openGallery() { Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, ReportConstants.GALLERY_INTENT); }
From source file:com.segma.trim.MainActivity.java
private void importFromGallery() { startActivityForResult(/*from w w w . j a va 2 s .c o m*/ new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI), REQUEST_CODE_GALLERY); }