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:ee.ria.DigiDoc.fragment.ContainerDetailsFragment.java
private void browseForFiles() { Intent intent = new Intent().setType("*/*").putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true) .setAction(Intent.ACTION_GET_CONTENT).addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(Intent.createChooser(intent, getText(R.string.select_file)), CHOOSE_FILE_REQUEST_ID); }
From source file:org.alfresco.mobile.android.application.managers.ActionUtils.java
/** * Allow to pick file with other apps./*from w w w. j a v a 2 s .co m*/ * * @return Activity for Result. */ public static void actionPickFile(Fragment fr, int requestCode) { if (fr == null) { return; } try { Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType("*/*"); i.addCategory(Intent.CATEGORY_OPENABLE); fr.startActivityForResult(Intent.createChooser(i, fr.getText(R.string.content_app_pick_file)), requestCode); } catch (ActivityNotFoundException e) { AlfrescoNotificationManager.getInstance(fr.getActivity()).showAlertCrouton(fr.getActivity(), R.string.error_unable_open_file); } }
From source file:net.zorgblub.typhon.fragment.LibraryFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { inflater.inflate(R.menu.library_menu, menu); UiUtils.Action toggleListener = () -> { if (switcher.getDisplayedChild() == 0) { bookAdapter = new BookCaseAdapter(); bookCaseView.setAdapter(bookAdapter); config.setLibraryView(LibraryView.BOOKCASE); } else {//from w w w . jav a2 s .c o m bookAdapter = new BookListAdapter(getActivity()); listView.setAdapter(bookAdapter); config.setLibraryView(LibraryView.LIST); } switcher.showNext(); refreshView(); }; onMenuPress(menu, R.id.shelves_view).thenDo(toggleListener); onMenuPress(menu, R.id.list_view).thenDo(toggleListener); onMenuPress(menu, R.id.scan_books).thenDo(this::showImportDialog); onMenuPress(menu, R.id.about).thenDo(dialogFactory.buildAboutDialog(context)::show); onMenuPress(menu, R.id.profile_day).thenDo(() -> switchToColourProfile(ColourProfile.DAY)); onMenuPress(menu, R.id.profile_night).thenDo(() -> switchToColourProfile(ColourProfile.NIGHT)); this.searchMenuItem = menu.findItem(R.id.menu_search); if (searchMenuItem != null) { final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchMenuItem); if (searchView != null) { searchView.setOnQueryTextListener(UiUtils.onQuery(this::performSearch)); MenuItemCompat.setOnActionExpandListener(searchMenuItem, onCollapse((() -> performSearch("")))); } else { searchMenuItem.setOnMenuItemClickListener(item -> { dialogFactory.showSearchDialog(R.string.search_library, R.string.enter_query, this::performSearch, context); return 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(getActivity(), intent)) { onMenuPress(menu, R.id.open_file).thenDo(this::launchFileManager); } else { menu.findItem(R.id.open_file).setVisible(false); } }
From source file:org.gnucash.android.ui.account.AccountsActivity.java
/** * Starts Intent chooser for selecting a GnuCash accounts file to import. * The accounts are actually imported in onActivityResult *//* w ww .j a v a 2 s.co m*/ public void importAccounts() { Intent pickIntent = new Intent(Intent.ACTION_GET_CONTENT); pickIntent.setType("application/octet-stream"); Intent chooser = Intent.createChooser(pickIntent, "Select GnuCash account file"); startActivityForResult(chooser, REQUEST_PICK_ACCOUNTS_FILE); }
From source file:bucci.dev.freestyle.TimerActivity.java
public void chooseSong() { Intent intent = new Intent(); intent.setAction(Intent.ACTION_GET_CONTENT); intent.setType(MP3_MIME_TYPE);// w w w . j a v a 2 s .c o m startActivityForResult(intent, REQ_CODE_CHOOSE_SONG); }
From source file:com.givon.anhao.activity.AnhaoMainActivity.java
/** * //from w w w . j av a 2s . c o m */ private void selectFileFromLocal() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); startActivityForResult(intent, ChatActivity.REQUEST_CODE_SELECT_FILE); }
From source file:org.petero.droidfish.activities.EditBoard.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case EDIT_DIALOG: { final int SIDE_TO_MOVE = 0; final int CLEAR_BOARD = 1; final int INITIAL_POS = 2; final int CASTLING_FLAGS = 3; final int EN_PASSANT_FILE = 4; final int MOVE_COUNTERS = 5; final int COPY_POSITION = 6; final int PASTE_POSITION = 7; final int GET_FEN = 8; List<CharSequence> lst = new ArrayList<CharSequence>(); List<Integer> actions = new ArrayList<Integer>(); lst.add(getString(R.string.side_to_move)); actions.add(SIDE_TO_MOVE);// www . ja va2 s. c om lst.add(getString(R.string.clear_board)); actions.add(CLEAR_BOARD); lst.add(getString(R.string.initial_position)); actions.add(INITIAL_POS); lst.add(getString(R.string.castling_flags)); actions.add(CASTLING_FLAGS); lst.add(getString(R.string.en_passant_file)); actions.add(EN_PASSANT_FILE); lst.add(getString(R.string.move_counters)); actions.add(MOVE_COUNTERS); lst.add(getString(R.string.copy_position)); actions.add(COPY_POSITION); lst.add(getString(R.string.paste_position)); actions.add(PASTE_POSITION); if (DroidFish.hasFenProvider(getPackageManager())) { lst.add(getString(R.string.get_fen)); actions.add(GET_FEN); } final List<Integer> finalActions = actions; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.edit_board); builder.setItems(lst.toArray(new CharSequence[lst.size()]), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { switch (finalActions.get(item)) { case SIDE_TO_MOVE: showDialog(SIDE_DIALOG); setSelection(-1); checkValidAndUpdateMaterialDiff(); break; case CLEAR_BOARD: { Position pos = new Position(); cb.setPosition(pos); setSelection(-1); checkValidAndUpdateMaterialDiff(); break; } case INITIAL_POS: { try { Position pos = TextIO.readFEN(TextIO.startPosFEN); cb.setPosition(pos); setSelection(-1); checkValidAndUpdateMaterialDiff(); } catch (ChessParseError e) { } break; } case CASTLING_FLAGS: removeDialog(CASTLE_DIALOG); showDialog(CASTLE_DIALOG); setSelection(-1); checkValidAndUpdateMaterialDiff(); break; case EN_PASSANT_FILE: removeDialog(EP_DIALOG); showDialog(EP_DIALOG); setSelection(-1); checkValidAndUpdateMaterialDiff(); break; case MOVE_COUNTERS: removeDialog(MOVCNT_DIALOG); showDialog(MOVCNT_DIALOG); setSelection(-1); checkValidAndUpdateMaterialDiff(); break; case COPY_POSITION: { setPosFields(); String fen = TextIO.toFEN(cb.pos) + "\n"; ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); clipboard.setText(fen); setSelection(-1); break; } case PASTE_POSITION: { ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE); if (clipboard.hasText()) { String fen = clipboard.getText().toString(); setFEN(fen); } break; } case GET_FEN: Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType("application/x-chess-fen"); try { startActivityForResult(i, RESULT_GET_FEN); } catch (ActivityNotFoundException e) { Toast.makeText(getApplicationContext(), e.getMessage(), Toast.LENGTH_LONG).show(); } } } }); AlertDialog alert = builder.create(); return alert; } case SIDE_DIALOG: { AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.select_side_to_move_first); final int selectedItem = (cb.pos.whiteMove) ? 0 : 1; builder.setSingleChoiceItems(new String[] { getString(R.string.white), getString(R.string.black) }, selectedItem, new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int id) { if (id == 0) { // white to move cb.pos.setWhiteMove(true); checkValidAndUpdateMaterialDiff(); dialog.cancel(); } else { cb.pos.setWhiteMove(false); checkValidAndUpdateMaterialDiff(); dialog.cancel(); } } }); AlertDialog alert = builder.create(); return alert; } case CASTLE_DIALOG: { final CharSequence[] items = { getString(R.string.white_king_castle), getString(R.string.white_queen_castle), getString(R.string.black_king_castle), getString(R.string.black_queen_castle) }; boolean[] checkedItems = { cb.pos.h1Castle(), cb.pos.a1Castle(), cb.pos.h8Castle(), cb.pos.a8Castle() }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.castling_flags); builder.setMultiChoiceItems(items, checkedItems, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { Position pos = new Position(cb.pos); boolean a1Castle = pos.a1Castle(); boolean h1Castle = pos.h1Castle(); boolean a8Castle = pos.a8Castle(); boolean h8Castle = pos.h8Castle(); switch (which) { case 0: h1Castle = isChecked; break; case 1: a1Castle = isChecked; break; case 2: h8Castle = isChecked; break; case 3: a8Castle = isChecked; break; } int castleMask = 0; if (a1Castle) castleMask |= 1 << Position.A1_CASTLE; if (h1Castle) castleMask |= 1 << Position.H1_CASTLE; if (a8Castle) castleMask |= 1 << Position.A8_CASTLE; if (h8Castle) castleMask |= 1 << Position.H8_CASTLE; pos.setCastleMask(castleMask); cb.setPosition(pos); checkValidAndUpdateMaterialDiff(); } }); AlertDialog alert = builder.create(); return alert; } case EP_DIALOG: { final CharSequence[] items = { "A", "B", "C", "D", "E", "F", "G", "H", getString(R.string.none) }; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(R.string.select_en_passant_file); builder.setSingleChoiceItems(items, getEPFile(), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int item) { setEPFile(item); dialog.cancel(); } }); AlertDialog alert = builder.create(); return alert; } case MOVCNT_DIALOG: { View content = View.inflate(this, R.layout.edit_move_counters, null); final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setView(content); builder.setTitle(R.string.edit_move_counters); final EditText halfMoveClock = (EditText) content.findViewById(R.id.ed_cnt_halfmove); final EditText fullMoveCounter = (EditText) content.findViewById(R.id.ed_cnt_fullmove); halfMoveClock.setText(String.format(Locale.US, "%d", cb.pos.halfMoveClock)); fullMoveCounter.setText(String.format(Locale.US, "%d", cb.pos.fullMoveCounter)); final Runnable setCounters = new Runnable() { public void run() { try { int halfClock = Integer.parseInt(halfMoveClock.getText().toString()); int fullCount = Integer.parseInt(fullMoveCounter.getText().toString()); cb.pos.halfMoveClock = halfClock; cb.pos.fullMoveCounter = fullCount; } catch (NumberFormatException nfe) { Toast.makeText(getApplicationContext(), R.string.invalid_number_format, Toast.LENGTH_SHORT) .show(); } } }; builder.setPositiveButton("Ok", new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { setCounters.run(); } }); builder.setNegativeButton("Cancel", null); final Dialog dialog = builder.create(); fullMoveCounter.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) { setCounters.run(); dialog.cancel(); return true; } return false; } }); return dialog; } } return null; }
From source file:com.gabm.fancyplaces.ui.MainWindow.java
protected void showFileSelector() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("application/zip"); startActivityForResult(intent, REQUEST_FILE_SELECTION); }
From source file:com.waz.zclient.pages.main.profile.camera.CameraFragment.java
public void openGallery() { Intent i;//from www.j a v a 2 s .c o m if (BuildConfig.IS_TEST_GALLERY_ALLOWED && TestingGalleryUtils.isCustomGalleryInstalled(getActivity().getPackageManager())) { i = new Intent("com.wire.testing.GET_PICTURE"); i.addCategory(Intent.CATEGORY_DEFAULT); i.setType(INTENT_GALLERY_TYPE); } else { i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType(INTENT_GALLERY_TYPE); } getActivity().startActivityForResult(i, REQUEST_GALLERY_CODE); getActivity().overridePendingTransition(R.anim.camera_in, R.anim.camera_out); }
From source file:net.zorgblub.typhon.fragment.LibraryFragment.java
private void launchFileManager() { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("file/*"); intent.addCategory(Intent.CATEGORY_OPENABLE); this.intentCallBack = (int resultCode, Intent data) -> { if (resultCode == Activity.RESULT_OK && data != null) { Intent readingIntent = new Intent(getActivity(), ReadingActivity.class); readingIntent.setData(data.getData()); getActivity().setResult(Activity.RESULT_OK, readingIntent); getActivity().startActivityIfNeeded(readingIntent, 99); }/* w w w. ja v a 2 s. c o m*/ }; try { startActivityForResult(intent, REQUEST_CODE_GET_CONTENT); } catch (ActivityNotFoundException e) { // No compatible file manager was found. Toast.makeText(getActivity(), getString(R.string.install_oi), Toast.LENGTH_SHORT).show(); } }