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.esri.android.rt.map.PopupFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mPopupContainer == null || mPopupContainer.getPopupCount() <= 0) return true; Popup popup = mPopupContainer.getCurrentPopup(); switch (item.getItemId()) { case R.id.menu_camera: startActivityForResult(new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI), 1); break;//from w w w. j av a2 s . c om case R.id.menu_delete: deleteFeature(popup); break; case R.id.menu_edit: editFeature(popup); break; case R.id.menu_save: saveFeature(popup); break; } return true; }
From source file:com.google.android.apps.paco.FindExperimentsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mainLayout = (ViewGroup) getLayoutInflater().inflate(R.layout.find_experiments, null); setContentView(mainLayout);/*from ww w . j av a2 s .c o m*/ Intent intent = getIntent(); if (intent.getData() == null) { intent.setData(ExperimentColumns.CONTENT_URI); } userPrefs = new UserPreferences(this); list = (ListView) findViewById(R.id.find_experiments_list); createListHeader(); createRefreshHeader(); experimentProviderUtil = new ExperimentProviderUtil(this); refreshButton = (Button) findViewById(R.id.RefreshExperimentsButton2); refreshButton.setVisibility(View.VISIBLE); refreshButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (!isConnected()) { showDialogById(DownloadHelper.NO_NETWORK_CONNECTION); } else { refreshList(); } } }); progressBar = (ProgressBar) findViewById(R.id.findExperimentsProgressBar); reloadAdapter(); list.setItemsCanFocus(true); list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> listview, View textview, int position, long id) { Experiment experiment = experiments.get(position); Uri uri = ContentUris.withAppendedId(getIntent().getData(), experiment.getServerId()); String action = getIntent().getAction(); if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action)) { // The caller is waiting for us to return an experiment selected by // the user. The have clicked on one, so return it now. setResult(RESULT_OK, new Intent().setData(uri)); } else { Intent experimentIntent = new Intent(FindExperimentsActivity.this, ExperimentDetailActivity.class); experimentIntent.setData(uri); startActivityForResult(experimentIntent, JOIN_REQUEST_CODE); } } }); registerForContextMenu(list); }
From source file:org.yammp.fragment.QueryFragment.java
@Override public void onListItemClick(ListView l, View v, int position, long id) { // Dialog doesn't allow us to wait for a result, so we need to store // the info we need for when the dialog posts its result mQueryCursor.moveToPosition(position); if (mQueryCursor.isBeforeFirst() || mQueryCursor.isAfterLast()) return;// ww w. ja va 2s . c om String selectedType = mQueryCursor.getString(mQueryCursor.getColumnIndexOrThrow(Audio.Media.MIME_TYPE)); if ("artist".equals(selectedType)) { Intent intent = new Intent(Intent.ACTION_PICK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/album"); intent.putExtra("artist", Long.valueOf(id).toString()); startActivity(intent); } else if ("album".equals(selectedType)) { Intent intent = new Intent(Intent.ACTION_PICK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); intent.putExtra("album", Long.valueOf(id).toString()); startActivity(intent); } else if (position >= 0 && id >= 0) { long[] list = new long[] { id }; mUtils.playAll(list, 0); } else { Log.e("QueryBrowser", "invalid position/id: " + position + "/" + id); } }
From source file:com.android.gallery3d.app.Gallery.java
private void initializeByIntent() { Intent intent = getIntent();//from w w w . ja v a 2s .c o m String action = intent.getAction(); if (Intent.ACTION_GET_CONTENT.equalsIgnoreCase(action)) { startGetContent(intent); } else if (Intent.ACTION_PICK.equalsIgnoreCase(action)) { // We do NOT really support the PICK intent. Handle it as // the GET_CONTENT. However, we need to translate the type // in the intent here. Log.w(TAG, "action PICK is not supported"); String type = Utils.ensureNotNull(intent.getType()); if (type.startsWith("vnd.android.cursor.dir/")) { if (type.endsWith("/image")) intent.setType("image/*"); if (type.endsWith("/video")) intent.setType("video/*"); } startGetContent(intent); } else if (Intent.ACTION_VIEW.equalsIgnoreCase(action) || ACTION_REVIEW.equalsIgnoreCase(action)) { startViewAction(intent); } else { startDefaultPage(); } }
From source file:com.zhongsou.souyue.ui.webview.CustomWebChromeClient.java
/** * /*from ww w . j a v a 2s. co m*/ */ private void openChosePic() { Intent intent = new Intent(Intent.ACTION_PICK); intent.setDataAndType(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); fragment.startActivityForResult(intent, REQ_CHOOSE); }
From source file:pl.edu.agh.flowers.addeditflower.AddEditFlowerFragment.java
private void openGallery() { if (ActivityCompat.checkSelfPermission(getContext(), android.Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(getActivity(), new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE }, 1); }//from ww w. j a v a 2 s . c o m Intent intent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.INTERNAL_CONTENT_URI); startActivityForResult(intent, GALLERY_CODE); }
From source file:com.pimp.companionforband.fragments.theme.ThemeFragment.java
@Override public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); imageView = (ImageView) view.findViewById(R.id.selected_me_tile_image_view); SharedPreferences settings = getActivity().getSharedPreferences("MyPrefs", 0); Drawable meTileDrawable = null;/*w ww.ja va2 s . c o m*/ String encoded = settings.getString("me_tile_image", "null"); if (!encoded.equals("null")) { byte[] imageAsBytes = Base64.decode(encoded.getBytes(), Base64.DEFAULT); meTileDrawable = new BitmapDrawable(getResources(), BitmapFactory.decodeByteArray(imageAsBytes, 0, imageAsBytes.length)); } if (meTileDrawable != null) imageView.setImageDrawable(meTileDrawable); Button btnUpdateMe, btnPickMe, btnUpdateTheme, btnGetMeTile, btnGetTheme, btnGetColors; btnPickMe = (Button) view.findViewById(R.id.pick_me_tile_button); btnPickMe.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_PICK); intent.setType("image/*"); startActivityForResult(intent, 9); } }); btnGetMeTile = (Button) view.findViewById(R.id.get_me_tile_button); btnGetMeTile.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new getMeTask().execute(); } }); btnUpdateMe = (Button) view.findViewById(R.id.update_me_tile_button); btnUpdateMe.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { bitmapDrawable = (BitmapDrawable) imageView.getDrawable(); new appTask().execute(); } }); SharedPreferences sharedPreferences = getContext().getSharedPreferences("MyPrefs", 0); base = sharedPreferences.getInt("base", -16777216); highlight = sharedPreferences.getInt("highLight", -16777216); lowlight = sharedPreferences.getInt("lowLight", -16777216); secondaryText = sharedPreferences.getInt("secondaryText", -16777216); highContrast = sharedPreferences.getInt("highContrast", -16777216); muted = sharedPreferences.getInt("muted", -16777216); btnGetTheme = (Button) view.findViewById(R.id.get_theme_button); btnGetTheme.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new getThemeTask().execute(view); } }); btnUpdateTheme = (Button) view.findViewById(R.id.update_theme_button); btnUpdateTheme.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { new themeTask().execute(); } }); btnBase = (Button) view.findViewById(R.id.base); btnHighlight = (Button) view.findViewById(R.id.highlight); btnLowlight = (Button) view.findViewById(R.id.lowlight); btnSecondaryText = (Button) view.findViewById(R.id.secondaryText); btnHighContrast = (Button) view.findViewById(R.id.highContrast); btnMuted = (Button) view.findViewById(R.id.muted); btnBase.setBackgroundColor(Color.parseColor(String.format("#%06X", (0xFFFFFF & base)))); btnHighlight.setBackgroundColor(Color.parseColor(String.format("#%06X", (0xFFFFFF & highlight)))); btnLowlight.setBackgroundColor(Color.parseColor(String.format("#%06X", (0xFFFFFF & lowlight)))); btnSecondaryText.setBackgroundColor(Color.parseColor(String.format("#%06X", (0xFFFFFF & secondaryText)))); btnHighContrast.setBackgroundColor(Color.parseColor(String.format("#%06X", (0xFFFFFF & highContrast)))); btnMuted.setBackgroundColor(Color.parseColor(String.format("#%06X", (0xFFFFFF & muted)))); btnGetColors = (Button) view.findViewById(R.id.get_colors_button); btnGetColors.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { bitmapDrawable = (BitmapDrawable) imageView.getDrawable(); if (bitmapDrawable.getBitmap() != null && !bitmapDrawable.getBitmap().isRecycled()) { Palette.from(bitmapDrawable.getBitmap()).generate(paletteListener); } } }); }
From source file:com.example.android.mmschallenge.MainActivity.java
/** * * On click of the Choose Picture button, enables the user to * choose an image from the Gallery.//from w w w. j a va 2s . c o m * * @param view View (Choose Picture button) that was clicked. */ public void choosePic(View view) { // Choose a picture. Intent galleryIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(galleryIntent, IMAGE_PICK); }
From source file:gov.nasa.arc.geocam.geocam.CameraPreviewActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Window and view properties requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.camera_preview); // Load bitmap from intent data and display in imageview mImageUri = getIntent().getData();//from w w w . j a va 2s . c o m try { mImageData = new JSONObject(getIntent().getExtras().getString("data")); } catch (JSONException e1) { Log.d(GeoCamMobile.DEBUG_ID, "Error unserializing JSON data from intent"); mImageData = new JSONObject(); } try { final BitmapFactory.Options opts = new BitmapFactory.Options(); opts.inSampleSize = 4; InputStream in = getContentResolver().openInputStream(mImageUri); Bitmap bitmap = BitmapFactory.decodeStream(in, null, opts); //Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), mImageUri); ImageView imageView = (ImageView) findViewById(R.id.camera_preview_imageview); imageView.setAdjustViewBounds(true); imageView.setScaleType(ScaleType.CENTER_INSIDE); imageView.setImageBitmap(bitmap); } catch (FileNotFoundException e) { Log.d(GeoCamMobile.DEBUG_ID, "Error loading bitmap in CameraPreviewActivity"); } SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); String defaultNotes = settings.getString(GeoCamMobile.SETTINGS_DEFAULT_NOTES_KEY, ""); // Set default notes EditText notesText = (EditText) findViewById(R.id.camera_preview_edittext); notesText.setText(defaultNotes + " "); // Buttons mFireButton = (ImageButton) findViewById(R.id.camera_preview_fire_button); mFireButton.setImageDrawable(getResources().getDrawable(R.drawable.fire_icon_default)); mFireButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setClass(CameraPreviewActivity.this, FireIconActivity.class); startActivityForResult(intent, PICK_ICON_REQUEST); } }); final ImageButton deleteButton = (ImageButton) findViewById(R.id.camera_preview_delete_button); deleteButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { CameraPreviewActivity.this.showDialog(DIALOG_DELETE_PHOTO); } }); final ImageButton saveButton = (ImageButton) findViewById(R.id.camera_preview_save_button); saveButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mImageNote = ((EditText) findViewById(R.id.camera_preview_edittext)).getText().toString(); Log.d(GeoCamMobile.DEBUG_ID, "Setting image note to: " + mImageNote); saveWithAnnotation(); } }); mForeground = new ForegroundTracker(this); }
From source file:org.kaaproject.kaa.demo.iotworld.smarthome.fragment.device.PhotoDeviceFragment.java
private void uploadPhoto() { if (mControlsEnabled) { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_SELECT_IMAGE); }//from w ww .j av a2s .com }