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:uk.co.pjmobile.mobile_apps.page_turner_reader.ReadingActivity.java
@Override public boolean onPrepareOptionsMenu(Menu menu) { // if (this.tocDialog == null) { // initTocDialog(); // }/*from w w w . ja v a 2s .c o m*/ MenuItem nightMode = menu.findItem(R.id.profile_night); MenuItem dayMode = menu.findItem(R.id.profile_day); MenuItem showToc = menu.findItem(R.id.show_toc); // MenuItem sync = menu.findItem(R.id.manual_sync); showToc.setEnabled(true); // sync.setEnabled(config.isSyncEnabled()); if (config.getColourProfile() == ColourProfile.DAY) { dayMode.setVisible(false); nightMode.setVisible(true); } else { dayMode.setVisible(true); nightMode.setVisible(false); } // Only show open file item if we have a file manager installed Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("file/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); if (!isIntentAvailable(this, intent)) { // menu.findItem(R.id.open_file).setVisible(false); } getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); return super.onPrepareOptionsMenu(menu); }
From source file:com.example.zf_android.trade.ApplyDetailActivity.java
private void setupItem(LinearLayout item, int itemType, final String key, final String value) { switch (itemType) { case ITEM_EDIT: { TextView tvKey = (TextView) item.findViewById(R.id.apply_detail_key); EditText etValue = (EditText) item.findViewById(R.id.apply_detail_value); if (!TextUtils.isEmpty(key)) tvKey.setText(key);/*from ww w . ja v a2 s . co m*/ if (!TextUtils.isEmpty(value)) etValue.setText(value); break; } case ITEM_CHOOSE: { TextView tvKey = (TextView) item.findViewById(R.id.apply_detail_key); TextView tvValue = (TextView) item.findViewById(R.id.apply_detail_value); if (!TextUtils.isEmpty(key)) tvKey.setText(key); if (!TextUtils.isEmpty(value)) tvValue.setText(value); break; } case ITEM_UPLOAD: { TextView tvKey = (TextView) item.findViewById(R.id.apply_detail_key); final TextView tvValue = (TextView) item.findViewById(R.id.apply_detail_value); if (!TextUtils.isEmpty(key)) tvKey.setText(key); tvValue.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { uploadingTextView = tvValue; AlertDialog.Builder builder = new AlertDialog.Builder(ApplyDetailActivity.this); final String[] items = getResources().getStringArray(R.array.apply_detail_upload); builder.setItems(items, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(intent, REQUEST_UPLOAD_IMAGE); break; } case 1: { String state = Environment.getExternalStorageState(); if (state.equals(Environment.MEDIA_MOUNTED)) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); File outDir = Environment .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES); if (!outDir.exists()) { outDir.mkdirs(); } File outFile = new File(outDir, System.currentTimeMillis() + ".jpg"); photoPath = outFile.getAbsolutePath(); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(outFile)); intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); startActivityForResult(intent, REQUEST_TAKE_PHOTO); } else { CommonUtil.toastShort(ApplyDetailActivity.this, getString(R.string.toast_no_sdcard)); } break; } } } }); builder.show(); } }); break; } case ITEM_VIEW: { TextView tvKey = (TextView) item.findViewById(R.id.apply_detail_key); ImageButton ibView = (ImageButton) item.findViewById(R.id.apply_detail_view); if (!TextUtils.isEmpty(key)) tvKey.setText(key); ibView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent i = new Intent(ApplyDetailActivity.this, ImageViewer.class); i.putExtra("url", value); i.putExtra("justviewer", true); startActivity(i); } }); } } }
From source file:info.tellmetime.TellmetimeActivity.java
public void pickImage(View view) { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(intent, REQUEST_CODE); }
From source file:com.stikyhive.stikyhive.ChattingActivity.java
private void showFileChooser() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("File/*"); /*try {// w w w .j a v a 2 s . co m startActivityForResult(intent, FILE_SELECT_CODE); } catch (android.content.ActivityNotFoundException ex) { // Potentially direct the user to the Market with a Dialog Toast.makeText(this, "Please install a File Manager.", Toast.LENGTH_SHORT).show(); }*/ // special intent for Samsung file manager Intent sIntent = new Intent("com.sec.android.app.myfiles.PICK_DATA"); // if you want any file type, you can skip next line // sIntent.putExtra("CONTENT_TYPE", "*/*"); sIntent.addCategory(Intent.CATEGORY_DEFAULT); Intent chooserIntent; if (getPackageManager().resolveActivity(sIntent, 0) != null) { // it is device with samsung file manager chooserIntent = Intent.createChooser(sIntent, "Open file"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { intent }); } else { chooserIntent = Intent.createChooser(intent, "Open file"); } try { startActivityForResult(chooserIntent, FILE_SELECT_CODE); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getApplicationContext(), "No suitable File Manager was found.", Toast.LENGTH_SHORT) .show(); } }
From source file:cliq.com.cliqgram.fragments.CameraFragment.java
@Override public void onClick(View view) { switch (view.getId()) { case R.id.button_capture: takePicture();//from w w w .j av a 2 s .c o m break; case R.id.button_flash: if (flashOn) { flashOn = false; ImageUtil.loadResToView(getActivity(), R.drawable.icon_flash_off, buttonFlash, 0.7f); } else { flashOn = true; ImageUtil.loadResToView(getActivity(), R.drawable.icon_flash_on, buttonFlash, 0.7f); } break; case R.id.button_grid: // TODO if (gridOn) { gridOn = false; myGridView.setVisibility(View.INVISIBLE); ImageUtil.loadResToView(getActivity(), R.drawable.icon_grid_off, buttonGrid, 0.7f); } else { gridOn = true; myGridView.setVisibility(View.VISIBLE); ImageUtil.loadResToView(getActivity(), R.drawable.icon_grid_on, buttonGrid, 0.7f); } break; case R.id.button_gallery: Intent intent = new Intent(); // Show only images, no videos or anything else intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); // Always show the chooser (if there are multiple options available) startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); break; } }
From source file:us.theparamountgroup.android.inventory.EditorActivity.java
public void openImageSelector(View view) { Intent intent;//from www . j a v a2s. co m Log.e(LOG_TAG, "While is set and the ifs are worked through."); if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); } else { intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); } Log.e(LOG_TAG, "Check write to external permissions"); intent.setType("image/*"); startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_IMAGE_REQUEST); }
From source file:com.android.mms.ui.MessageUtils.java
private static void selectMediaByType(Context context, int requestCode, String contentType, boolean localFilesOnly) { if (context instanceof Activity) { Intent innerIntent = new Intent(Intent.ACTION_GET_CONTENT); innerIntent.setType(contentType); /// M: @{ if (FeatureOption.MTK_DRM_APP) { innerIntent.putExtra(OmaDrmStore.DrmIntentExtra.EXTRA_DRM_LEVEL, OmaDrmStore.DrmIntentExtra.LEVEL_SD); }//from w ww . j a v a 2 s .c om /// @} if (localFilesOnly) { innerIntent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); } Intent wrapperIntent = Intent.createChooser(innerIntent, null); ((Activity) context).startActivityForResult(wrapperIntent, requestCode); } }
From source file:com.ximai.savingsmore.save.activity.AddGoodsAcitivyt.java
private void openAlbum() { Intent openAlbumIntent = new Intent(Intent.ACTION_GET_CONTENT); openAlbumIntent.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*"); startActivityForResult(openAlbumIntent, PICK_FROM_IMAGE); }
From source file:com.digitalarx.android.ui.activity.FileDisplayActivity.java
@Override protected Dialog onCreateDialog(int id) { Dialog dialog = null;/* ww w. j a v a 2 s.c o m*/ AlertDialog.Builder builder; switch (id) { case DIALOG_SHORT_WAIT: { ProgressDialog working_dialog = new ProgressDialog(this); working_dialog.setMessage(getResources().getString(R.string.wait_a_moment)); working_dialog.setIndeterminate(true); working_dialog.setCancelable(false); dialog = working_dialog; break; } case DIALOG_CHOOSE_UPLOAD_SOURCE: { String[] items = null; String[] allTheItems = { getString(R.string.actionbar_upload_files), getString(R.string.actionbar_upload_from_apps), getString(R.string.actionbar_failed_instant_upload) }; String[] commonItems = { getString(R.string.actionbar_upload_files), getString(R.string.actionbar_upload_from_apps) }; if (InstantUploadActivity.IS_ENABLED) items = allTheItems; else items = commonItems; builder = new AlertDialog.Builder(this); builder.setTitle(R.string.actionbar_upload); builder.setItems(items, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { if (item == 0) { // if (!mDualPane) { Intent action = new Intent(FileDisplayActivity.this, UploadFilesActivity.class); action.putExtra(UploadFilesActivity.EXTRA_ACCOUNT, FileDisplayActivity.this.getAccount()); startActivityForResult(action, ACTION_SELECT_MULTIPLE_FILES); // } else { // TODO create and handle new fragment // LocalFileListFragment // } } else if (item == 1) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult( Intent.createChooser(action, getString(R.string.upload_chooser_title)), ACTION_SELECT_CONTENT_FROM_APPS); } else if (item == 2 && InstantUploadActivity.IS_ENABLED) { Intent action = new Intent(FileDisplayActivity.this, InstantUploadActivity.class); action.putExtra(FileUploader.KEY_ACCOUNT, FileDisplayActivity.this.getAccount()); startActivity(action); } } }); dialog = builder.create(); break; } case DIALOG_CERT_NOT_SAVED: { builder = new AlertDialog.Builder(this); builder.setMessage(getResources().getString(R.string.ssl_validator_not_saved)); builder.setCancelable(false); builder.setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); }; }); dialog = builder.create(); break; } default: dialog = null; } return dialog; }
From source file:cn.kangeqiu.kq.activity.ChatActivity.java
/** * //from w w w . java2 s . co m */ private void selectFileFromLocal() { Intent intent = null; if (Build.VERSION.SDK_INT < 19) { intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); } else { intent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); } startActivityForResult(intent, REQUEST_CODE_SELECT_FILE); }