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:im.vector.activity.RoomActivity.java
/** * Launch the files selection intent//w w w .jav a 2s. co m */ private void launchFileSelectionIntent() { Intent fileIntent = new Intent(Intent.ACTION_GET_CONTENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { fileIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } fileIntent.setType("*/*"); startActivityForResult(fileIntent, REQUEST_FILES); }
From source file:com.msdpe.storagedemo.BlobsActivity.java
protected void selectImage() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); startActivityForResult(intent, 1111); }
From source file:sjizl.com.FileUploadTest2.java
public void openGallery(int req_code) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select file to upload "), req_code); }
From source file:geert.stef.sm.beheerautokm.Overview.java
public void addGalleryImage(View view) { if (view.getId() == R.id.btnAddGalleryImage) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(intent, REQUEST_CODE_SELECT); }//w w w .j a v a 2s.c o m }
From source file:com.logilite.vision.camera.CameraLauncher.java
/** * Get image from photo library.//ww w .j av a2 s.com * * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param srcType The album to get image from. * @param returnType Set the type of image to return. */ // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do! public void getImage(int srcType, int returnType) { Intent intent = new Intent(); String title = GET_PICTURE; if (this.mediaType == PICTURE) { intent.setType("image/*"); } else if (this.mediaType == VIDEO) { intent.setType("video/*"); title = GET_VIDEO; } else if (this.mediaType == ALLMEDIA) { // I wanted to make the type 'image/*, video/*' but this does not work on all versions // of android so I had to go with the wildcard search. intent.setType("*/*"); title = GET_All; } intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); if (this.cordova != null) { this.cordova.startActivityForResult((CordovaPlugin) this, Intent.createChooser(intent, new String(title)), (srcType + 1) * 16 + returnType + 1); } }
From source file:com.juegoteca.actividades.Opciones.java
/** * Shows the simplified settings UI if the device configuration if the * device configuration dictates that a simplified, single-pane UI should be * shown./*from w ww .ja v a 2 s. c om*/ */ @SuppressWarnings("deprecation") private void setupSimplePreferencesScreen() { if (!isSimplePreferences(this)) { return; } final SharedPreferences settings = getSharedPreferences("UserInfo", 0); // In the simplified UI, fragments are not used at all and we instead // use the older PreferenceActivity APIs. addPreferencesFromResource(R.xml.pref_container); // Add 'general' preferences. PreferenceCategory fakeHeader = new PreferenceCategory(this); fakeHeader.setTitle(R.string.pref_header_general); getPreferenceScreen().addPreference(fakeHeader); addPreferencesFromResource(R.xml.pref_general); CheckBoxPreference preferenciaOrden = (CheckBoxPreference) findPreference("orden_ultimos_anadidos"); preferenciaOrden.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue.toString().equals("true")) { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("orden_ultimos_fecha_compra", true); editor.commit(); } else { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("orden_ultimos_fecha_compra", false); editor.commit(); } return true; } }); ListPreference preferenciaModeda = (ListPreference) findPreference("currencys"); preferenciaModeda.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { SharedPreferences.Editor editor = settings.edit(); editor.putString("currency", newValue.toString()); editor.commit(); return true; } }); CheckBoxPreference preferenciaDetalle = (CheckBoxPreference) findPreference("detalle_imagen"); preferenciaDetalle.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue.toString().equals("true")) { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("detalle_imagen", true); editor.commit(); } else { SharedPreferences.Editor editor = settings.edit(); editor.putBoolean("detalle_imagen", false); editor.commit(); } return true; } }); SwitchPreference preferenciaTwitter = (SwitchPreference) findPreference("twitter"); preferenciaTwitter.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { @Override public boolean onPreferenceChange(Preference preference, Object newValue) { if (newValue instanceof Boolean) { boolean isChecked = (boolean) newValue; if (isChecked) { Intent intent = new Intent(getApplicationContext(), TwitterActivity.class); startActivity(intent); return true; } } return true; } }); // Add 'data and sync' preferences, and a corresponding header. PreferenceCategory fakeHeader2 = new PreferenceCategory(this); fakeHeader2.setTitle(R.string.pref_header_data); getPreferenceScreen().addPreference(fakeHeader2); addPreferencesFromResource(R.xml.pref_datos_seguridad); // Establece las acciones al hacer click en las preferencias Preference preferenciaCopiaExportar = findPreference("exportar_copia_seguridad"); preferenciaCopiaExportar.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Toast t; if (!utilidades.baseDatosEsVacia()) { new CopiaSeguridadFichero().execute(); } else { t = Toast.makeText(getApplicationContext(), getString(R.string.no_data_backup), Toast.LENGTH_SHORT); t.show(); } return true; } }); Preference preferenciaCopiaImportar = findPreference("importar_restaurar_seguridad"); preferenciaCopiaImportar.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { AlertDialog.Builder builder = new AlertDialog.Builder(Opciones.this); builder.setMessage(R.string.alerta_restaurar_texto).setTitle(R.string.alerta_restaurar_titulo); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("application/zip"); intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(Intent.createChooser(intent, "Escoja el fichero de copia..."), FILE_SELECT_CODE); } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog return; } }); AlertDialog dialog = builder.create(); dialog.show(); return true; } }); Preference preferenciaBorrar = findPreference("borrar_todo"); preferenciaBorrar.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { utilidades.borrarTodosDatos(true); return true; } }); // Add 'otros' preferences. PreferenceCategory fakeHeader3 = new PreferenceCategory(this); fakeHeader3.setTitle(R.string.pref_header_otros); getPreferenceScreen().addPreference(fakeHeader3); addPreferencesFromResource(R.xml.pref_otros); Resources res = getResources(); // String versionName = res.getString(R.string.app_version); String versionName = ""; try { versionName = getPackageManager().getPackageInfo(getPackageName(), 0).versionName; } catch (NameNotFoundException e) { // versionName = res.getString(R.string.app_version); } String version = res.getString(R.string.pref_title_version, versionName); Preference preferenciaInicioSesion = findPreference("about"); preferenciaInicioSesion.setTitle(version); Preference preferenciaLicencia = findPreference("licenses"); preferenciaLicencia.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { public boolean onPreferenceClick(Preference preference) { Intent intent = new Intent(getApplicationContext(), AcercaDe.class); startActivity(intent); return true; } }); }
From source file:cx.ring.fragments.AccountCreationFragment.java
private void presentFilePicker() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); startActivityForResult(intent, FILE_SELECT_CODE); }
From source file:com.proalias.awesomestatus.MainActivity.java
private void onClickPostPhoto() { // Launch the gallery picker to specify a photo Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE); }
From source file:com.kdao.cmpe235_project.UploadActivity.java
private void initUI() { /**//from ww w . j ava2 s . co m * This adapter takes the data in transferRecordMaps and displays it, * with the keys of the map being related to the columns in the adapter */ simpleAdapter = new SimpleAdapter(this, transferRecordMaps, R.layout.record_item, new String[] { "checked", "fileName", "progress", "bytes", "state", "percentage" }, new int[] { R.id.radioButton1, R.id.textFileName, R.id.progressBar1, R.id.textBytes, R.id.textState, R.id.textPercentage }); simpleAdapter.setViewBinder(new SimpleAdapter.ViewBinder() { @Override public boolean setViewValue(View view, Object data, String textRepresentation) { switch (view.getId()) { case R.id.radioButton1: RadioButton radio = (RadioButton) view; radio.setChecked((Boolean) data); return true; case R.id.textFileName: TextView fileName = (TextView) view; fileName.setText((String) data); return true; case R.id.progressBar1: ProgressBar progress = (ProgressBar) view; progress.setProgress((Integer) data); return true; case R.id.textBytes: TextView bytes = (TextView) view; bytes.setText((String) data); return true; case R.id.textState: TextView state = (TextView) view; state.setText(((TransferState) data).toString()); return true; case R.id.textPercentage: TextView percentage = (TextView) view; percentage.setText((String) data); return true; } return false; } }); setListAdapter(simpleAdapter); // Updates checked index when an item is clicked getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int pos, long id) { if (checkedIndex != pos) { transferRecordMaps.get(pos).put("checked", true); if (checkedIndex >= 0) { transferRecordMaps.get(checkedIndex).put("checked", false); } checkedIndex = pos; updateButtonAvailability(); simpleAdapter.notifyDataSetChanged(); } } }); //btnUploadFile = (Button) findViewById(R.id.buttonUploadFile); btnUploadImage = (Button) findViewById(R.id.buttonUploadImage); btnUploadAudio = (Button) findViewById(R.id.buttonUploadAudio); btnUploadVideo = (Button) findViewById(R.id.buttonUploadVideo); btnPause = (Button) findViewById(R.id.buttonPause); btnResume = (Button) findViewById(R.id.buttonResume); btnCancel = (Button) findViewById(R.id.buttonCancel); btnDelete = (Button) findViewById(R.id.buttonDelete); btnPauseAll = (Button) findViewById(R.id.buttonPauseAll); btnCancelAll = (Button) findViewById(R.id.buttonCancelAll); btnUploadImage.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isTreeSelected) { System.out.println(">>>>> Start uploading photos... <<<<<<<"); Intent intent = new Intent(); if (Build.VERSION.SDK_INT >= 19) { // For Android versions of KitKat or later, we use a // different intent to ensure // we can get the file path from the returned intent URI intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); } else { intent.setAction(Intent.ACTION_GET_CONTENT); } APIurl = "/tree/" + treeId + "/photo"; intent.setType("image/*"); startActivityForResult(intent, 0); } else { Toast.makeText(getApplicationContext(), Config.UPLOAD_NOTREE_ERR, Toast.LENGTH_LONG).show(); } } }); btnUploadAudio.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isTreeSelected) { Intent intent = new Intent(); if (Build.VERSION.SDK_INT >= 19) { // For Android versions of KitKat or later, we use a // different intent to ensure // we can get the file path from the returned intent URI intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); } else { intent.setAction(Intent.ACTION_GET_CONTENT); } APIurl = "/tree/" + treeId + "/audio"; intent.setType("audio/*"); startActivityForResult(intent, 0); } else { Toast.makeText(getApplicationContext(), Config.UPLOAD_NOTREE_ERR, Toast.LENGTH_LONG).show(); } } }); btnUploadVideo.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (isTreeSelected) { Intent intent = new Intent(); if (Build.VERSION.SDK_INT >= 19) { // For Android versions of KitKat or later, we use a // different intent to ensure // we can get the file path from the returned intent URI intent.setAction(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); } else { intent.setAction(Intent.ACTION_GET_CONTENT); } APIurl = "/tree/" + treeId + "/video"; intent.setType("video/*"); startActivityForResult(intent, 0); } else { Toast.makeText(getApplicationContext(), Config.UPLOAD_NOTREE_ERR, Toast.LENGTH_LONG).show(); } } }); btnPause.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Make sure the user has selected a transfer if (checkedIndex >= 0 && checkedIndex < observers.size()) { Boolean paused = transferUtility.pause(observers.get(checkedIndex).getId()); /** * If paused does not return true, it is likely because the * user is trying to pause an upload that is not in a * pausable state (For instance it is already paused, or * canceled). */ if (!paused) { Toast.makeText(UploadActivity.this, Config.UPLOAD_PAUSE_ERR, Toast.LENGTH_SHORT).show(); } } } }); btnResume.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Make sure the user has selected a transfer if (checkedIndex >= 0 && checkedIndex < observers.size()) { TransferObserver resumed = transferUtility.resume(observers.get(checkedIndex).getId()); // Sets a new transfer listener to the original observer. // This will overwrite existing listener. observers.get(checkedIndex).setTransferListener(new UploadListener()); /** * If resume returns null, it is likely because the transfer * is not in a resumable state (For instance it is already * running). */ if (resumed == null) { Toast.makeText(UploadActivity.this, Config.UPLOAD_RESUME_ERR, Toast.LENGTH_SHORT).show(); } } } }); btnCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Make sure a transfer is selected if (checkedIndex >= 0 && checkedIndex < observers.size()) { Boolean canceled = transferUtility.cancel(observers.get(checkedIndex).getId()); /** * If cancel returns false, it is likely because the * transfer is already canceled */ if (!canceled) { Toast.makeText(UploadActivity.this, Config.UPLOAD_TRANSFER_ERR, Toast.LENGTH_SHORT).show(); } } } }); btnDelete.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // Make sure a transfer is selected if (checkedIndex >= 0 && checkedIndex < observers.size()) { transferUtility.deleteTransferRecord(observers.get(checkedIndex).getId()); observers.remove(checkedIndex); transferRecordMaps.remove(checkedIndex); checkedIndex = INDEX_NOT_CHECKED; updateButtonAvailability(); updateList(); } } }); btnPauseAll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { transferUtility.pauseAllWithType(TransferType.UPLOAD); } }); btnCancelAll.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { transferUtility.cancelAllWithType(TransferType.UPLOAD); } }); updateButtonAvailability(); }