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.zhongzilu.bit100.view.activity.EditorActivity.java
@Override public void onClick(View v) { if (R.id.id_shortcut_insert_photo == v.getId()) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK);// Pick an item fromthe intent.setType("image/*");// startActivityForResult(intent, SYSTEM_GALLERY); return;/*from w w w .j av a 2 s .co m*/ } else if (R.id.id_shortcut_insert_link == v.getId()) { //? insertLink(); return; } else if (R.id.id_shortcut_grid == v.getId()) { //? insertTable(); return; } //? mEditorFragment.getPerformEditable().onClick(v); }
From source file:org.musicmod.android.app.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;//from w w w.java 2 s . co m } 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 }; MusicUtils.playAll(getActivity(), list, 0); } else { Log.e("QueryBrowser", "invalid position/id: " + position + "/" + id); } }
From source file:im.vector.activity.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (CommonActivityUtils.shouldRestartApp()) { Log.e(LOG_TAG, "Restart the application."); CommonActivityUtils.restartApp(this); }/*from w w w . j a v a 2 s . c o m*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); mMediasCache = Matrix.getInstance(this).getMediasCache(); // add any known session LinearLayout globalLayout = (LinearLayout) findViewById(R.id.settings_layout); TextView profileHeader = (TextView) findViewById(R.id.settings_profile_information_header); int pos = globalLayout.indexOfChild(profileHeader); for (MXSession session : Matrix.getMXSessions(this)) { final MXSession fSession = session; LinearLayout profileLayout = (LinearLayout) getLayoutInflater() .inflate(R.layout.account_section_settings, null); mLinearLayoutBySession.put(session, profileLayout); pos++; globalLayout.addView(profileLayout, pos); refreshProfileThumbnail(session, profileLayout); ImageView avatarView = (ImageView) profileLayout.findViewById(R.id.imageView_avatar); avatarView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mUpdatingSession = fSession; Intent fileIntent = new Intent(Intent.ACTION_PICK); fileIntent.setType("image/*"); startActivityForResult(fileIntent, REQUEST_IMAGE); } }); MyUser myUser = session.getMyUser(); TextView matrixIdTextView = (TextView) profileLayout.findViewById(R.id.textView_matrix_id); matrixIdTextView.setText(myUser.userId); final Button saveButton = (Button) profileLayout.findViewById(R.id.button_save); EditText displayNameEditText = (EditText) profileLayout.findViewById(R.id.editText_displayName); displayNameEditText.setText(myUser.displayname); displayNameEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateSaveButton(saveButton); } @Override public void afterTextChanged(Editable s) { } }); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveChanges(fSession); } }); } // Config information String versionName = ""; try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); versionName = pInfo.versionName; } catch (Exception e) { } TextView consoleVersionTextView = (TextView) findViewById(R.id.textView_matrixConsoleVersion); consoleVersionTextView.setText(getString(R.string.settings_config_console_version, versionName)); TextView sdkVersionTextView = (TextView) findViewById(R.id.textView_matrixSDKVersion); sdkVersionTextView.setText(getString(R.string.settings_config_sdk_version, versionName)); TextView buildNumberTextView = (TextView) findViewById(R.id.textView_matrixBuildNumber); buildNumberTextView.setText(getString(R.string.settings_config_build_number, "")); TextView userIdTextView = (TextView) findViewById(R.id.textView_configUsers); String config = ""; int sessionIndex = 1; Collection<MXSession> sessions = Matrix.getMXSessions(this); for (MXSession session : sessions) { if (sessions.size() > 1) { config += "\nAccount " + sessionIndex + " : \n"; sessionIndex++; } config += String.format(getString(R.string.settings_config_home_server), session.getCredentials().homeServer); config += "\n"; config += String.format(getString(R.string.settings_config_user_id), session.getMyUser().userId); if (sessions.size() > 1) { config += "\n"; } } userIdTextView.setText(config); // room settings final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); listenBoxUpdate(preferences, R.id.checkbox_useGcm, getString(R.string.settings_key_use_google_cloud_messaging), true); listenBoxUpdate(preferences, R.id.checkbox_displayAllEvents, getString(R.string.settings_key_display_all_events), false); listenBoxUpdate(preferences, R.id.checkbox_hideUnsupportedEvenst, getString(R.string.settings_key_hide_unsupported_events), true); listenBoxUpdate(preferences, R.id.checkbox_sortByLastSeen, getString(R.string.settings_key_sort_by_last_seen), true); listenBoxUpdate(preferences, R.id.checkbox_displayLeftMembers, getString(R.string.settings_key_display_left_members), false); listenBoxUpdate(preferences, R.id.checkbox_displayPublicRooms, getString(R.string.settings_key_display_public_rooms_recents), true); final Button clearCacheButton = (Button) findViewById(R.id.button_clear_cache); clearCacheButton.setText(getString(R.string.clear_cache) + " (" + computeApplicationCacheSize() + ")"); clearCacheButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Matrix.getInstance(SettingsActivity.this).reloadSessions(SettingsActivity.this); } }); final Button notificationsRuleButton = (Button) findViewById(R.id.button_notifications_rule); notificationsRuleButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { launchNotificationsActivity(); } }); final GcmRegistrationManager gcmRegistrationManager = Matrix.getInstance(this) .getSharedGcmRegistrationManager(); refreshGCMEntries(); final EditText pusherUrlEditText = (EditText) findViewById(R.id.editText_gcm_pusher_url); pusherUrlEditText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { gcmRegistrationManager.setPusherUrl(pusherUrlEditText.getText().toString()); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); final EditText pusherProfileEditText = (EditText) findViewById(R.id.editText_gcm_pusher_profile_tag); pusherProfileEditText.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { gcmRegistrationManager.setPusherFileTag(pusherProfileEditText.getText().toString()); } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); managePedingGCMregistration(); }
From source file:com.lithiumli.fiction.NowPlayingActivity.java
public void selectArtistImage() { Intent photoPickerIntent = new Intent(Intent.ACTION_PICK); photoPickerIntent.setType("image/*"); editingArtist = getService().getQueue().getCurrent().getArtist(); startActivityForResult(photoPickerIntent, SELECT_PHOTO); }
From source file:de.awisus.refugeeaidleipzig.views.profile.FragmentEditOffer.java
private void startChooser() { Intent intentGalerie;/*from w ww . j a v a2 s. c o m*/ intentGalerie = new Intent(Intent.ACTION_PICK); intentGalerie.setType("image/*"); Intent chooser = new Intent(Intent.ACTION_CHOOSER); chooser.putExtra(Intent.EXTRA_INTENT, intentGalerie); chooser.putExtra(Intent.EXTRA_TITLE, R.string.titel_select_image); Intent[] intentArray = { new Intent(MediaStore.ACTION_IMAGE_CAPTURE) }; chooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooser, WAEHLE_BILD); }
From source file:es.uma.lcc.lockpic.MainActivity.java
/** * UI callbacks/*from w w w. j a va 2 s .c o m*/ */ public void buttonEncryptClick(View view) { // intent for launching the gallery Intent i = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(i, ACTIVITY_PICK_IMAGE_ENC); }
From source file:org.matrix.console.activity.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (CommonActivityUtils.shouldRestartApp()) { Log.e(LOG_TAG, "Restart the application."); CommonActivityUtils.restartApp(this); }/*from www. ja v a2s .com*/ super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); mMediasCache = Matrix.getInstance(this).getMediasCache(); // add any known session LinearLayout globalLayout = (LinearLayout) findViewById(R.id.settings_layout); TextView profileHeader = (TextView) findViewById(R.id.settings_profile_information_header); int pos = globalLayout.indexOfChild(profileHeader); for (MXSession session : Matrix.getMXSessions(this)) { final MXSession fSession = session; LinearLayout profileLayout = (LinearLayout) getLayoutInflater() .inflate(R.layout.account_section_settings, null); mLinearLayoutByMatrixId.put(session.getCredentials().userId, profileLayout); pos++; globalLayout.addView(profileLayout, pos); refreshProfileThumbnail(session, profileLayout); ImageView avatarView = (ImageView) profileLayout.findViewById(R.id.imageView_avatar); avatarView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { mUpdatingSessionId = fSession.getCredentials().userId; Intent fileIntent = new Intent(Intent.ACTION_PICK); fileIntent.setType("image/*"); startActivityForResult(fileIntent, REQUEST_IMAGE); } }); MyUser myUser = session.getMyUser(); TextView matrixIdTextView = (TextView) profileLayout.findViewById(R.id.textView_matrix_id); matrixIdTextView.setText(myUser.userId); final Button saveButton = (Button) profileLayout.findViewById(R.id.button_save); EditText displayNameEditText = (EditText) profileLayout.findViewById(R.id.editText_displayName); displayNameEditText.setText(myUser.displayname); displayNameEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { updateSaveButton(saveButton); } @Override public void afterTextChanged(Editable s) { } }); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { saveChanges(fSession); } }); } // Config information String versionName = ""; try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); versionName = pInfo.versionName; } catch (Exception e) { } TextView consoleVersionTextView = (TextView) findViewById(R.id.textView_matrixConsoleVersion); consoleVersionTextView.setText(getString(R.string.settings_config_console_version, versionName)); TextView sdkVersionTextView = (TextView) findViewById(R.id.textView_matrixSDKVersion); sdkVersionTextView.setText(getString(R.string.settings_config_sdk_version, versionName)); TextView buildNumberTextView = (TextView) findViewById(R.id.textView_matrixBuildNumber); buildNumberTextView.setText(getString(R.string.settings_config_build_number, "")); TextView userIdTextView = (TextView) findViewById(R.id.textView_configUsers); String config = ""; int sessionIndex = 1; Collection<MXSession> sessions = Matrix.getMXSessions(this); for (MXSession session : sessions) { if (sessions.size() > 1) { config += "\nAccount " + sessionIndex + " : \n"; sessionIndex++; } config += String.format(getString(R.string.settings_config_home_server), session.getHomeserverConfig().getHomeserverUri().toString()); config += "\n"; config += String.format(getString(R.string.settings_config_user_id), session.getMyUser().userId); if (sessions.size() > 1) { config += "\n"; } } userIdTextView.setText(config); // room settings final SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); listenBoxUpdate(preferences, R.id.checkbox_useGcm, getString(R.string.settings_key_use_google_cloud_messaging), true); listenBoxUpdate(preferences, R.id.checkbox_displayAllEvents, getString(R.string.settings_key_display_all_events), false); listenBoxUpdate(preferences, R.id.checkbox_hideUnsupportedEvenst, getString(R.string.settings_key_hide_unsupported_events), true); listenBoxUpdate(preferences, R.id.checkbox_sortByLastSeen, getString(R.string.settings_key_sort_by_last_seen), true); listenBoxUpdate(preferences, R.id.checkbox_displayLeftMembers, getString(R.string.settings_key_display_left_members), false); listenBoxUpdate(preferences, R.id.checkbox_displayPublicRooms, getString(R.string.settings_key_display_public_rooms_recents), true); listenBoxUpdate(preferences, R.id.checkbox_rageshake, getString(R.string.settings_key_use_rage_shake), true); final Button clearCacheButton = (Button) findViewById(R.id.button_clear_cache); clearCacheButton.setText(getString(R.string.clear_cache) + " (" + computeApplicationCacheSize() + ")"); clearCacheButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Matrix.getInstance(SettingsActivity.this).reloadSessions(SettingsActivity.this); } }); final Button notificationsRuleButton = (Button) findViewById(R.id.button_notifications_rule); notificationsRuleButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { launchNotificationsActivity(); } }); final GcmRegistrationManager gcmRegistrationManager = Matrix.getInstance(this) .getSharedGcmRegistrationManager(); refreshGCMEntries(); managePedingGCMregistration(); }
From source file:com.google.cloud.solutions.smashpix.MainActivity.java
/** * Gets a picture from the built in image gallery. *//*from ww w. j a v a 2 s . co m*/ public void getPicture() { Intent intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); intent.setType(INTENT_IMAGE_PICK_FILTER); startActivityForResult(Intent.createChooser(intent, getResources().getString(R.string.select_image)), Constants.SELECT_PICTURE); }
From source file:com.example.android.lnotifications.OtherMetadataFragment.java
private void findContact() { Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_PICK_CONTACT); }
From source file:org.catnut.ui.ComposeTweetActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (!mSlidingPaneLayout.isOpen()) { mSlidingPaneLayout.openPane();/* w ww. ja v a 2s . co m*/ } switch (item.getItemId()) { case R.id.pref: startActivity(SingleFragmentActivity.getIntent(this, SingleFragmentActivity.PREF)); break; case R.id.action_gallery: // todo: ????Orz if (mUris != null && mUris.size() > 0) { Toast.makeText(this, getString(R.string.only_one_pic_hint), Toast.LENGTH_LONG).show(); } else { startActivityForResult(new Intent(Intent.ACTION_PICK).setType("image/*"), 1); } break; case R.id.action_shorten: shorten(); break; case R.id.action_camera: // same as above if (mUris != null && mUris.size() > 0) { break; } Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (intent.resolveActivity(getPackageManager()) != null) { mTmpUri = CatnutUtils.createImageFile(); if (mTmpUri != null) { intent.putExtra(MediaStore.EXTRA_OUTPUT, mTmpUri); } startActivityForResult(intent, CAMERA); } else { Toast.makeText(this, getString(R.string.device_not_support), Toast.LENGTH_SHORT).show(); } break; case R.id.action_discovery: int cursor = mText.getSelectionStart(); mText.getText().append("##"); mText.setSelection(cursor + 1); mText.requestFocus(); break; default: break; } return super.onOptionsItemSelected(item); }