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.schoentoon.connectbot.PubkeyListActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuItem generatekey = menu.add(R.string.pubkey_generate); generatekey.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); generatekey.setIcon(android.R.drawable.ic_menu_manage); generatekey.setIntent(new Intent(PubkeyListActivity.this, GeneratePubkeyActivity.class)); MenuItem importkey = menu.add(R.string.pubkey_import); importkey.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); importkey.setIcon(android.R.drawable.ic_menu_upload); importkey.setOnMenuItemClickListener(new OnMenuItemClickListener() { public boolean onMenuItemClick(MenuItem item) { Uri sdcard = Uri.fromFile(Environment.getExternalStorageDirectory()); String pickerTitle = getString(R.string.pubkey_list_pick); // Try to use OpenIntent's file browser to pick a file Intent intent = new Intent(FileManagerIntents.ACTION_PICK_FILE); intent.setData(sdcard);// w w w . ja va2 s. c om intent.putExtra(FileManagerIntents.EXTRA_TITLE, pickerTitle); intent.putExtra(FileManagerIntents.EXTRA_BUTTON_TEXT, getString(android.R.string.ok)); try { startActivityForResult(intent, REQUEST_CODE_PICK_FILE); } catch (ActivityNotFoundException e) { // If OI didn't work, try AndExplorer intent = new Intent(Intent.ACTION_PICK); intent.setDataAndType(sdcard, MIME_TYPE_ANDEXPLORER_FILE); intent.putExtra(ANDEXPLORER_TITLE, pickerTitle); try { startActivityForResult(intent, REQUEST_CODE_PICK_FILE); } catch (ActivityNotFoundException e1) { pickFileSimple(); } } return true; } }); return true; }
From source file:com.polyvi.xface.view.XWebViewClient.java
/** * ?url?? url ??url//from w w w . j a v a 2 s . c o m */ private boolean startSysApplication(String url) { Intent intent = null; if (url.contains("content://media/external")) { intent = new Intent(Intent.ACTION_PICK); } else { intent = new Intent(Intent.ACTION_VIEW); } intent.setData(Uri.parse(url)); try { mSystemContext.getContext().startActivity(intent); } catch (ActivityNotFoundException e) { XLog.e(CLASS_NAME, e.toString()); } return true; }
From source file:com.stfalcon.contentmanager.ContentManager.java
/** * Pick image or video content from storage or google acc * * @param content image or video/*from ww w . j a v a 2 s . com*/ */ public void pickContent(Content content) { savedTask = CONTENT_PICKER; savedContent = content; if (isStoragePermissionGranted(activity, fragment)) { this.targetFile = createFile(content); if (Build.VERSION.SDK_INT < 19) { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType(content.toString()); if (fragment == null) { activity.startActivityForResult(photoPickerIntent, CONTENT_PICKER); } else { fragment.startActivityForResult(photoPickerIntent, CONTENT_PICKER); } } else { Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT); photoPickerIntent.setType(content.toString()); photoPickerIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); photoPickerIntent.addCategory(Intent.CATEGORY_OPENABLE); if (photoPickerIntent.resolveActivity(activity.getPackageManager()) != null) { if (fragment == null) { activity.startActivityForResult(photoPickerIntent, CONTENT_PICKER); } else { fragment.startActivityForResult(photoPickerIntent, CONTENT_PICKER); } } } } }
From source file:com.example.deii.Fragments.UpdateProfileFragment.java
protected void startGallery() { // TODO Auto-generated method stub Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, GALLERY_REQUEST); }
From source file:com.ceino.chaperonandroid.activities.LicenseActivity.java
private void selectImage() { final CharSequence[] options = { "Take Photo", "Choose from Gallery", "Cancel" }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Add Photo!"); builder.setItems(options, new DialogInterface.OnClickListener() { @Override//w ww . j a va2 s . co m public void onClick(DialogInterface dialog, int item) { if (options[item].equals("Take Photo")) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File f = new File(Environment.getExternalStorageDirectory(), "temp.jpg"); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); startActivityForResult(intent, 1); } else if (options[item].equals("Choose from Gallery")) { Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, 2); } else if (options[item].equals("Cancel")) { dialog.dismiss(); } } }); builder.show(); }
From source file:com.money.manager.ex.fragment.SearchFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (container == null) return null; //create view View view = (LinearLayout) inflater.inflate(R.layout.search_activity, container, false); //create listener amount OnClickListener onClickAmount = new OnClickListener() { @Override/*from ww w. j a v a2s. c o m*/ public void onClick(View v) { double amount = 0; if (v.getTag() != null && v.getTag() instanceof Double) { amount = (Double) ((TextView) v).getTag(); } InputAmountDialog dialog = InputAmountDialog.getInstance(v.getId(), amount); dialog.show(getSherlockActivity().getSupportFragmentManager(), dialog.getClass().getSimpleName()); } }; //To Amount txtToAmount = (TextView) view.findViewById(R.id.textViewFromAmount); txtToAmount.setOnClickListener(onClickAmount); //From Amount txtFromAmount = (TextView) view.findViewById(R.id.textViewToAmount); txtFromAmount.setOnClickListener(onClickAmount); // accountlist <> to populate the spin spinAccount = (Spinner) view.findViewById(R.id.spinnerAccount); if (mAccountList == null) { mAccountList = new MoneyManagerOpenHelper(getSherlockActivity()).getListAccounts( mApplication.getAccountsOpenVisible(), mApplication.getAccountFavoriteVisible()); mAccountList.add(0, null); for (int i = 0; i <= mAccountList.size() - 1; i++) { if (mAccountList.get(i) != null) { mAccountNameList.add(mAccountList.get(i).getAccountName()); mAccountIdList.add(mAccountList.get(i).getAccountId()); } else { mAccountNameList.add(""); mAccountIdList.add(AdapterView.INVALID_POSITION); } } } // checkbox cbxDeposit = (CheckBox) view.findViewById(R.id.checkBoxDeposit); cbxTransfer = (CheckBox) view.findViewById(R.id.checkBoxTransfer); cbxWithdrawal = (CheckBox) view.findViewById(R.id.checkBoxWithdrawal); // create adapter for spinAccount ArrayAdapter<String> adapterAccount = new ArrayAdapter<String>(getSherlockActivity(), R.layout.sherlock_spinner_item, mAccountNameList); adapterAccount.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinAccount.setAdapter(adapterAccount); //Payee txtSelectPayee = (TextView) view.findViewById(R.id.textViewSelectPayee); txtSelectPayee.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getSherlockActivity(), PayeeActivity.class); intent.setAction(Intent.ACTION_PICK); startActivityForResult(intent, REQUEST_PICK_PAYEE); } }); //Category txtSelectCategory = (TextView) view.findViewById(R.id.textViewSelectCategory); txtSelectCategory.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getSherlockActivity(), CategorySubCategoryExpandableListActivity.class); intent.setAction(Intent.ACTION_PICK); startActivityForResult(intent, REQUEST_PICK_CATEGORY); } }); if (mStatusItems.size() <= 0) { // arrays to manage Status mStatusItems.add(""); mStatusValues.add(""); mStatusItems.addAll(Arrays.asList(getResources().getStringArray(R.array.status_items))); mStatusValues.addAll(Arrays.asList(getResources().getStringArray(R.array.status_values))); } // create adapter for spinnerStatus spinStatus = (Spinner) view.findViewById(R.id.spinnerStatus); ArrayAdapter<String> adapterStatus = new ArrayAdapter<String>(getSherlockActivity(), R.layout.sherlock_spinner_item, mStatusItems); adapterStatus.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinStatus.setAdapter(adapterStatus); // from date txtFromDate = (TextView) view.findViewById(R.id.textViewFromDate); txtFromDate.setOnClickListener(new OnDateButtonClickListener(txtFromDate)); // to date txtToDate = (TextView) view.findViewById(R.id.textViewToDate); txtToDate.setOnClickListener(new OnDateButtonClickListener(txtToDate)); // transaction number edtTransNumber = (EditText) view.findViewById(R.id.editTextTransNumber); // notes edtNotes = (EditText) view.findViewById(R.id.editTextNotes); return view; }
From source file:com.newshiqi.yushi.ProfileActivity.java
private void initView() { userInfo = MainApplication.getInstance().getUserInfo(); if (userInfo == null) { userInfo = new UserInfo(); userInfo.setMemberId(StringUtil.getSavedValue(SessionData.KEY_USERID)); userInfo.setUserType(StringUtil.getSavedValue(SessionData.KEY_USER_TYPE)); userInfo.setNickname(StringUtil.getSavedValue(SessionData.KEY_NICKNAME)); userInfo.setMobile(StringUtil.getSavedValue(SessionData.KEY_PHONE)); userInfo.setAvatar(StringUtil.getSavedValue(SessionData.KEY_USER_AVATAR)); }/* w w w . ja v a2 s .c o m*/ userType = userInfo.getUserType(); Bitmap bitmap = null; String avatar = Util.getImageUrl(userInfo.getAvatar()); /*if ("C".equals(userType) && userInfo.getCompany() != null) { if (!TextUtils.isEmpty(userInfo.getCompany().getLogo())) { avatar = Util.getImageUrl(userInfo.getCompany().getLogo()); } }*/ if (!TextUtils.isEmpty(avatar)) { bitmap = imgDownloader.downloadImage(avatar, new onImageLoaderListener() { @Override public void onImageLoader(Bitmap bitmap, String url) { if (bitmap != null) { bitmap = ImageUtil.resizeBitmapSmooth(bitmap, Util.dip2px(ProfileActivity.this, 60), Util.dip2px(ProfileActivity.this, 60)); bitmap = ImageUtil.getRoundedCornerBitmap(bitmap, Util.dip2px(ProfileActivity.this, 27)); user_icon.setImageBitmap(bitmap); } } }); } if (bitmap != null) { bitmap = ImageUtil.resizeBitmapSmooth(bitmap, Util.dip2px(this, 60), Util.dip2px(this, 60)); bitmap = ImageUtil.getRoundedCornerBitmap(bitmap, Util.dip2px(this, 27)); user_icon.setImageBitmap(bitmap); } else { user_icon.setImageResource(R.drawable.user_logined); } user_icon.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { uploadType = "avatar"; FileUtil.deleteFile(TEMP_FILE_NAME); try { tempFile = FileUtil.makeDIRAndCreateFile(TEMP_FILE_NAME); } catch (Exception e) { } Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);//android i.putExtra("crop", "true"); // i.putExtra("aspectX", 1); i.putExtra("output", Uri.fromFile(tempFile)); i.putExtra("outputFormat", "JPEG"); i.putExtra("aspectX", 1); //? ? X ? i.putExtra("aspectY", 1); i.putExtra("outputX", 350); i.putExtra("outputY", 350); startActivityForResult(i, 2); } }); // // if ("T".equals(userType)) { // if (userInfo.getTalent() != null) { // name = userInfo.getTalent().getName(); // } // } else if ("C".equals(userType)) { // if (userInfo.getCompany() != null) { // name = userInfo.getCompany().getName(); // } // } else { name = userInfo.getNickname(); // } if (TextUtils.isEmpty(name)) { initItem(R.id.p_username, getText(R.string.p_username), getString(R.string.not_defined), true); } else { initItem(R.id.p_username, getText(R.string.p_username), name, true); } mobile = userInfo.getMobile(); if (TextUtils.isEmpty(mobile)) { mobile = userInfo.getUsername(); } initItem(R.id.p_usertype, getText(R.string.p_usertype), getUserTypeDesp(userType), true); initItem(R.id.p_phone, getText(R.string.p_phonenum), mobile, true); initItem(R.id.p_modify_pwd, getText(R.string.p_modify_pwd), "", false); initViewByUserType(); }
From source file:org.dodgybits.shuffle.android.view.fragment.TaskPagerFragment.java
private void deferTask() { Task task = getSelectedTask();/* w w w . j av a 2 s . c o m*/ Intent intent = new Intent(Intent.ACTION_PICK); intent.setType(DateTimePickerActivity.TYPE); intent.putExtra(DateTimePickerActivity.DATETIME_VALUE, task.getStartDate()); intent.putExtra(DateTimePickerActivity.TITLE, getString(R.string.title_deferred_picker)); startActivityForResult(intent, DEFERRED_CODE); }
From source file:io.realm.scanner.MainActivity.java
private void dispatchSelectPhoto() { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); startActivityForResult(photoPickerIntent, REQUEST_SELECT_PHOTO); }
From source file:com.mobicage.rogerthat.GroupDetailActivity.java
private void getNewAvatar(boolean checkPermission) { T.UI();//from w w w . jav a 2s .c o m if (checkPermission) { final SafeRunnable continueRunnable = new SafeRunnable() { @Override protected void safeRun() throws Exception { getNewAvatar(false); } }; final SafeRunnable runnableCheckStorage = new SafeRunnable() { @Override protected void safeRun() throws Exception { if (askPermissionIfNeeded(Manifest.permission.WRITE_EXTERNAL_STORAGE, PERMISSION_REQUEST_CAMERA, continueRunnable, null)) return; continueRunnable.run(); } }; if (askPermissionIfNeeded(Manifest.permission.CAMERA, PERMISSION_REQUEST_CAMERA, runnableCheckStorage, null)) return; runnableCheckStorage.run(); return; } File image; try { image = getTmpUploadPhotoLocation(); } catch (IOException e) { L.d(e.getMessage()); UIUtils.showLongToast(getApplicationContext(), e.getMessage()); return; } image.delete(); mUriSavedImage = Uri.fromFile(image); Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, mUriSavedImage); cameraIntent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString()); Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); galleryIntent.putExtra(MediaStore.EXTRA_OUTPUT, mUriSavedImage); galleryIntent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.toString()); galleryIntent.setType("image/*"); PackageManager pm = getPackageManager(); final Intent chooserIntent = Intent.createChooser(galleryIntent, getString(R.string.select_source)); if (pm.hasSystemFeature(PackageManager.FEATURE_CAMERA)) { chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { cameraIntent }); } startActivityForResult(chooserIntent, PICK_IMAGE); }