List of usage examples for android.content Intent ACTION_GET_CONTENT
String ACTION_GET_CONTENT
To view the source code for android.content Intent ACTION_GET_CONTENT.
Click Source Link
From source file:com.regula.documentreader.MainActivity.java
private void startPictureChoosing() { Intent intent = new Intent(); intent.setType("image/*"); if (Build.VERSION.SDK_INT >= 18) { intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); }/*from ww w. j a v a2 s .c o m*/ intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), 1); }
From source file:org.gnucash.android.ui.BaseDrawerActivity.java
/** * Handler for the navigation drawer items * *//*w ww . j a va2s. co m*/ protected void selectItem(int position) { switch (position) { case 1: { //Open... files Intent pickIntent = new Intent(Intent.ACTION_GET_CONTENT); pickIntent.setType("application/*"); Intent chooser = Intent.createChooser(pickIntent, getString(R.string.title_select_gnucash_xml_file)); startActivityForResult(chooser, AccountsActivity.REQUEST_PICK_ACCOUNTS_FILE); } break; case 2: { //favorite accounts Intent intent = new Intent(this, AccountsActivity.class); intent.putExtra(AccountsActivity.EXTRA_TAB_INDEX, AccountsActivity.INDEX_FAVORITE_ACCOUNTS_FRAGMENT); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); } break; case 3: startActivity(new Intent(this, ChartReportActivity.class)); break; case 5: { //show scheduled transactions Intent intent = new Intent(this, ScheduledActionsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(ScheduledActionsActivity.EXTRA_DISPLAY_MODE, ScheduledActionsActivity.DisplayMode.TRANSACTION_ACTIONS); startActivity(intent); } break; case 6: { AccountsActivity.showExportDialog(this); } break; case 9: //scheduled backup Intent intent = new Intent(this, ScheduledActionsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(ScheduledActionsActivity.EXTRA_DISPLAY_MODE, ScheduledActionsActivity.DisplayMode.EXPORT_ACTIONS); startActivity(intent); break; case 10: //Settings activity startActivity(new Intent(this, SettingsActivity.class)); break; //TODO: add help option } // Highlight the selected item, update the title, and close the drawer mDrawerList.setItemChecked(position, true); // setTitle(mNavDrawerEntries[position]); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:com.example.android.wardrobe.HomeActivity.java
public void loadImage(final int what) { ContextOption[] items = new ContextOption[] { new ContextOption("Take picture from camera", R.drawable.camera), new ContextOption("Select picture from gallery", R.drawable.gallery) }; SimpleMenuAdapter contextMenuAdapter = new SimpleMenuAdapter(this, Arrays.asList(items)); new AlertDialog.Builder(this) // .setTitle("Share Appliction") .setAdapter(contextMenuAdapter, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int menuId) { Intent intent = null; switch (menuId) { case 0: addWhat = what;//from www . j a v a2 s . c om intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); mImageCaptureUri = Uri.fromFile(new File(Environment.getExternalStorageDirectory(), "tmp_avatar_" + String.valueOf(System.currentTimeMillis()) + ".png")); intent.putExtra(MediaStore.EXTRA_OUTPUT, mImageCaptureUri); intent.putExtra("outputFormat", Bitmap.CompressFormat.PNG.name()); try { intent.putExtra("return-data", true); startActivityForResult(intent, PICK_FROM_CAMERA); } catch (ActivityNotFoundException e) { e.printStackTrace(); /** * TODO show message to user */ } break; case 1: addWhat = what; intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Complete action using"), PICK_FROM_FILE); break; } } }).show(); }
From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.SafeProfileFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.safe_profile, container); // retrieve text and image from main activity imgbut = (ImageView) v.findViewById(R.id.profImg); // profile img whoText = (TextView) v.findViewById(R.id.profName); // profile name email = (TextView) v.findViewById(R.id.safe_profile_email); slogan = (TextView) v.findViewById(R.id.safe_profile_slogan); device = (TextView) v.findViewById(R.id.safe_profile_device); Intent i = getActivity().getIntent(); Bundle b = i.getExtras();/*from ww w . ja v a 2 s . c om*/ whoStr = b.getString("who"); safe_gidh = b.getString(Safe.P_SAFE_GIDH); safe_lid = b.getString(Safe.P_SAFE_LID); // safe_id = b.getInt(Safe.P_SAFE_ID) + 1; whoText.setText(whoStr); peer = D_Peer.getPeerByLID(safe_lid, true, false); boolean gotIcon = false; try { byte[] icon = peer.getIcon(); if (icon != null) { Bitmap bmp = BitmapFactory.decodeByteArray(icon, 0, icon.length - 1); imgbut.setImageBitmap(bmp); gotIcon = true; } } catch (Exception e) { e.printStackTrace(); } if (!gotIcon) { int imgPath = Integer.parseInt(b.getString("profImg")); Bitmap bmp = BitmapFactory.decodeResource(getResources(), imgPath); imgbut.setImageBitmap(bmp); } imgbut.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { byte[] icon = peer.getIcon(); if (icon != null) { ImageFragment fragment = ImageFragment.newInstance(icon); FragmentManager fm = getActivity().getSupportFragmentManager(); fragment.show(fm, "icon"); } if (icon == null) { int imgPath = R.drawable.placeholder; Bitmap bmp = BitmapFactory.decodeResource(getResources(), imgPath); icon = PhotoUtil.BitmapToByteArray(bmp, 100); ImageFragment fragment = ImageFragment.newInstance(icon); FragmentManager fm = getActivity().getSupportFragmentManager(); fragment.show(fm, "icon"); } } }); email.setText(peer.getEmail()); slogan.setText(peer.getSlogan()); String instances = null; String contacts_Date = null; String sync_Date = null; for (String _inst : peer._instances.keySet()) { String contact = Encoder.getGeneralizedTime(peer._instances.get(_inst).get_last_contact_date()); String sync = peer._instances.get(_inst).get_last_sync_date_str(); if (contact == null) contact = Util.__("NEVER"); if (sync == null) sync = Util.__("NEVER"); if (instances == null) { instances = _inst; contacts_Date = contact; sync_Date = sync; } else { instances += ", " + _inst; contacts_Date += ", " + contact; sync_Date += ", " + sync; } } device.setText(Util.getStringNonNullUnique(peer.getInstance()) + " / {" + instances + "}"); if (peer.getSK() != null) { ipAddress = (TextView) v.findViewById(R.id.safe_profile_ip); ipAddress.setText("Known Secret Key"); setProfilePhoto = (Button) v.findViewById(R.id.safe_profile_set_profile_photo); setProfilePhoto.setVisibility(View.VISIBLE); setProfilePhoto.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (Build.VERSION.SDK_INT < 19) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(intent, SELECT_PROFILE_PHOTO); } else { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.setType("image/*"); startActivityForResult(intent, SELECT_PPROFILE_PHOTO_KITKAT); } } }); } else { lastContact = (TextView) v.findViewById(R.id.safe_profile_last_contact); lastContact.setText(contacts_Date);//peer.getLastSyncDate(safe_lid)); ipAddress = (TextView) v.findViewById(R.id.safe_profile_ip); ipAddress.setText(sync_Date); /* * hideThisSafe = (Switch) * v.findViewById(R.id.switch_hide_this_safe); * hideThisSafe.setVisibility(View.VISIBLE); * * if (peer.getHidden() == false) hideThisSafe.setChecked(false); * else hideThisSafe.setChecked(true); * * hideThisSafe .setOnCheckedChangeListener(new * OnCheckedChangeListener() { * * @Override public void onCheckedChanged(CompoundButton buttonView, * boolean isChecked) { if (isChecked) { D_Peer.setHidden(peer, * true); peer.storeRequest(); peer.releaseReference(); } else { * D_Peer.setHidden(peer, false); peer.storeRequest(); * peer.releaseReference(); } * * } }); * * resetLastSyncDate = (Button) v * .findViewById(R.id.button_reset_LastSyncDate); * resetLastSyncDate.setVisibility(View.VISIBLE); * resetLastSyncDate.setOnClickListener(new OnClickListener() { * * @Override public void onClick(View v) { peer = * D_Peer.getPeerByPeer_Keep(peer); peer.setLastSyncDate(null); * peer.storeRequest(); peer.releaseReference(); * * for (D_PeerInstance i : peer._instances.values()) { Calendar date * = i.get_last_sync_date(); Log.i("last_sync_date", * "last sync date: " + date); } } }); */ sendMsg = (Button) v.findViewById(R.id.button_send_msg); sendMsg.setVisibility(View.VISIBLE); sendMsg.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent myIntent = new Intent(); myIntent.setClass(getActivity(), Chat.class); // pass data to chat myIntent.putExtra("who", whoStr); // myIntent.putExtra(Safe.P_SAFE_ID, safe_id); myIntent.putExtra(Safe.P_SAFE_LID, safe_lid); myIntent.putExtra(Safe.P_SAFE_GIDH, safe_gidh); myIntent.putExtra("profImg", String.valueOf(R.drawable.placeholder)); startActivity(myIntent); } }); /* * // set up switch access accessIt = (Switch) * v.findViewById(R.id.switch_access); * accessIt.setVisibility(View.VISIBLE); if (peer.getUsed() == true) * accessIt.setChecked(true); if (peer.getUsed() == false) * accessIt.setChecked(false); * * accessIt.setOnCheckedChangeListener(new OnCheckedChangeListener() * { * * @Override public void onCheckedChanged(CompoundButton buttonView, * boolean isChecked) { if (isChecked) { D_Peer.setUsed(peer, true); * } else { D_Peer.setUsed(peer, false); } } }); * * // set up switch block blockIt = (Switch) * v.findViewById(R.id.switch_block); * blockIt.setVisibility(View.VISIBLE); if (peer.getBlocked() == * true) blockIt.setChecked(true); if (peer.getBlocked() == false) * blockIt.setChecked(false); * * blockIt.setOnCheckedChangeListener(new OnCheckedChangeListener() * { * * @Override public void onCheckedChanged(CompoundButton buttonView, * boolean isChecked) { if (isChecked) { D_Peer.setBlocked(peer, * true); } else { D_Peer.setBlocked(peer, false); } } }); * * // set up switch serve serveIt = (Switch) * v.findViewById(R.id.switch_serve); * serveIt.setVisibility(View.VISIBLE); * * if (peer.getUsed() == true) serveIt.setChecked(true); if * (peer.getUsed() == false) serveIt.setChecked(false); * * serveIt.setOnCheckedChangeListener(new OnCheckedChangeListener() * { * * @Override public void onCheckedChanged(CompoundButton buttonView, * boolean isChecked) { if (isChecked) { D_Peer.setUsed(peer, true); * peer.storeRequest(); peer.releaseReference(); } else { * D_Peer.setUsed(peer, false); peer.storeRequest(); * peer.releaseReference(); } } }); */ } return super.onCreateView(inflater, container, savedInstanceState); }
From source file:eu.alefzero.owncloud.ui.activity.FileDisplayActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { boolean retval = true; switch (item.getItemId()) { case R.id.createDirectoryItem: { showDialog(DIALOG_CREATE_DIR);/*from w w w. j a v a 2s. c om*/ break; } case R.id.startSync: { ContentResolver.cancelSync(null, "org.owncloud"); // cancel the current synchronizations of any ownCloud account Bundle bundle = new Bundle(); bundle.putBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, true); ContentResolver.requestSync(AccountUtils.getCurrentOwnCloudAccount(this), "org.owncloud", bundle); break; } case R.id.action_upload: { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(Intent.createChooser(action, "Upload file from..."), ACTION_SELECT_FILE); break; } case R.id.action_settings: { Intent settingsIntent = new Intent(this, Preferences.class); startActivity(settingsIntent); break; } case R.id.about_app: { showDialog(DIALOG_ABOUT_APP); break; } case android.R.id.home: { if (mCurrentDir != null && mCurrentDir.getParentId() != 0) { onBackPressed(); } break; } default: retval = false; } return retval; }
From source file:de.schilldroid.carfuelly.Activities.CarDetailsActivity.java
public void initComponents() { // initialize components mViewName = (EditText) findViewById(R.id.car_details_name); mViewDescription = (EditText) findViewById(R.id.car_details_description); mViewManufacturer = (EditText) findViewById(R.id.car_details_manufacturer); mViewModel = (EditText) findViewById(R.id.car_details_model); mViewFirstRegistration = (EditText) findViewById(R.id.car_details_first_registration); mViewPower = (EditText) findViewById(R.id.car_details_power); mViewEngine = (EditText) findViewById(R.id.car_details_engine); mViewConfiguration = (EditText) findViewById(R.id.car_details_configuration); mViewPurchaseDate = (EditText) findViewById(R.id.car_details_purchase_date); mViewPrice = (EditText) findViewById(R.id.car_details_price); mViewLicensePlate = (EditText) findViewById(R.id.car_details_license_plate); mViewConsumptionUrban = (EditText) findViewById(R.id.car_details_consumption_urban); mViewConsumptionExtraUrban = (EditText) findViewById(R.id.car_details_consumption_extraurban); mViewConsumptionCombined = (EditText) findViewById(R.id.car_details_consumption_combined); // add date picker mViewFirstRegistration.setOnClickListener(new View.OnClickListener() { @Override//from w w w. j a v a 2 s . com public void onClick(View v) { DialogFragment datePicker = new CarDetailsDatePickerFragment(); Bundle args = new Bundle(); args.putInt(Consts.CarDetails.DATE_PICKER_CONTEXT, Consts.CarDetails.DATE_PICKER_CONTEXT_FIRST_REGISTRATION); datePicker.setArguments(args); datePicker.show(getSupportFragmentManager(), "datePicker"); } }); mViewPurchaseDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DialogFragment datePicker = new CarDetailsDatePickerFragment(); Bundle args = new Bundle(); args.putInt(Consts.CarDetails.DATE_PICKER_CONTEXT, Consts.CarDetails.DATE_PICKER_CONTEXT_PURCHASE_DATE); datePicker.setArguments(args); datePicker.show(getSupportFragmentManager(), "datePicker"); } }); // init listview mViewTankList = (ListView) findViewById(R.id.car_details_tank_list); mTankListAdapter = new CarDetailTankListAdapter(this); mViewTankList.setAdapter(mTankListAdapter); // implement add tank button mViewAddTank = (ImageView) findViewById(R.id.car_details_tank_add); mViewAddTank.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mTankListAdapter.addTank(); } }); // setup toolbar mToolbar = (Toolbar) findViewById(R.id.car_details_toolbar); mToolbar.setTitle(mTitle); setSupportActionBar(mToolbar); getSupportActionBar().setDisplayShowHomeEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); mFAB = (FloatingActionButton) findViewById(R.id.car_details_fab); mFAB.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Choose image"), Consts.CarDetails.REQUEST_PICK_IMAGE); } }); mToolbarImage = (ImageView) findViewById(R.id.car_details_toolbar_image); }
From source file:com.android.settings.users.EditUserPhotoController.java
private void choosePhoto() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT, null); intent.setType("image/*"); appendOutputExtra(intent, mTakePictureUri); mFragment.startActivityForResult(intent, REQUEST_CODE_CHOOSE_PHOTO); }
From source file:com.business.rushour.businessapp.TabOwnerRegistrationActivity.java
public void captureImage(View view) { final CharSequence[] options = { "Take Photo", "Choose from Gallery", "Cancel" }; AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext()); builder.setTitle("Add Photo!"); builder.setItems(options, new DialogInterface.OnClickListener() { @Override//from w w w . ja v a 2 s. c o m public void onClick(DialogInterface dialog, int item) { if (options[item].equals("Take Photo")) { try { final Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); //startActivityForResult(cameraIntent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE); fileUri = getOutputMediaFileUri(MEDIA_TYPE_IMAGE); cameraIntent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // start the image capture Intent startActivityForResult(cameraIntent, CAMERA_CAPTURE_IMAGE_REQUEST_CODE); } catch (ActivityNotFoundException anfe) { String errorMessage = "Whoops - your device doesn't support capturing images!"; //Toast toast = Toast.makeText(view.getContext(), errorMessage, Toast.LENGTH_SHORT); //toast.show(); } } else if (options[item].equals("Choose from Gallery")) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(intent, PICK_IMAGE_REQUEST); } else if (options[item].equals("Cancel")) { dialog.dismiss(); } } }); builder.show(); }
From source file:ca.rmen.android.scrumchatter.main.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_team_switch: mTeams.selectTeam(mTeam);// w w w . j av a2 s. c om return true; case R.id.action_team_rename: mTeams.renameTeam(mTeam); return true; case R.id.action_team_delete: mTeams.deleteTeam(mTeam); return true; case R.id.action_import: Intent importIntent = new Intent(Intent.ACTION_GET_CONTENT); importIntent.setType("file/*"); startActivityForResult( Intent.createChooser(importIntent, getResources().getText(R.string.action_import)), ACTIVITY_REQUEST_CODE_IMPORT); return true; case R.id.action_share: // Build a chooser dialog for the file format. ScrumChatterDialog.showChoiceDialog(this, R.string.export_choice_title, R.array.export_choices, -1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { String[] exportChoices = getResources().getStringArray(R.array.export_choices); FileExport fileExport = null; if (getString(R.string.export_format_excel).equals(exportChoices[which])) fileExport = new MeetingsExport(MainActivity.this); else if (getString(R.string.export_format_db).equals(exportChoices[which])) fileExport = new DBExport(MainActivity.this); shareFile(fileExport); } }); return true; case R.id.action_about: Intent intent = new Intent(this, AboutActivity.class); startActivity(intent); return true; } return super.onOptionsItemSelected(item); }
From source file:com.hivewallet.androidclient.wallet.ui.EditAddressBookEntryFragment.java
private void handlePickPhoto() { Intent imageIntent = new Intent(); imageIntent.setType("image/*"); imageIntent.setAction(Intent.ACTION_GET_CONTENT); Intent choiceIntent = Intent.createChooser(imageIntent, getString(R.string.edit_address_book_entry_dialog_photo_selection)); startActivityForResult(choiceIntent, REQUEST_CODE_PICK_PHOTO); }