List of usage examples for android.content Intent EXTRA_ALLOW_MULTIPLE
String EXTRA_ALLOW_MULTIPLE
To view the source code for android.content Intent EXTRA_ALLOW_MULTIPLE.
Click Source Link
From source file:com.android.documentsui.DocumentsActivity.java
private void buildDefaultState() { mState = new State(); final Intent intent = getIntent(); final String action = intent.getAction(); if (Intent.ACTION_OPEN_DOCUMENT.equals(action)) { mState.action = ACTION_OPEN;/*from ww w. jav a2 s. co m*/ } else if (Intent.ACTION_CREATE_DOCUMENT.equals(action)) { mState.action = ACTION_CREATE; } else if (Intent.ACTION_GET_CONTENT.equals(action)) { mState.action = ACTION_GET_CONTENT; } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) { mState.action = ACTION_MANAGE; } if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) { mState.allowMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false); } if (mState.action == ACTION_MANAGE) { mState.acceptMimes = new String[] { "*/*" }; mState.allowMultiple = true; } else if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) { mState.acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES); } else { mState.acceptMimes = new String[] { intent.getType() }; } mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false); mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false); mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this); }
From source file:cn.edu.wyu.documentviewer.DocumentsActivity.java
private void buildDefaultState() { mState = new State(); final Intent intent = virtualIntent; final String action = intent.getAction(); if (Intent.ACTION_OPEN_DOCUMENT.equals(action)) { mState.action = ACTION_OPEN;/* www. ja va 2 s . co m*/ } else if (Intent.ACTION_CREATE_DOCUMENT.equals(action)) { mState.action = ACTION_CREATE; } else if (Intent.ACTION_GET_CONTENT.equals(action)) { mState.action = ACTION_GET_CONTENT; } else if (DocumentsContract.ACTION_MANAGE_ROOT.equals(action)) { mState.action = ACTION_MANAGE; } if (mState.action == ACTION_OPEN || mState.action == ACTION_GET_CONTENT) { mState.allowMultiple = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false); } if (mState.action == ACTION_MANAGE) { mState.acceptMimes = new String[] { "*/*" }; mState.allowMultiple = true; } else if (intent.hasExtra(Intent.EXTRA_MIME_TYPES)) { mState.acceptMimes = intent.getStringArrayExtra(Intent.EXTRA_MIME_TYPES); } else { mState.acceptMimes = new String[] { intent.getType() }; } mState.localOnly = intent.getBooleanExtra(Intent.EXTRA_LOCAL_ONLY, false); mState.forceAdvanced = intent.getBooleanExtra(DocumentsContract.EXTRA_SHOW_ADVANCED, false); mState.showAdvanced = mState.forceAdvanced | SettingsActivity.getDisplayAdvancedDevices(this); }
From source file:com.farmerbb.notepad.fragment.NoteListFragment.java
@TargetApi(Build.VERSION_CODES.KITKAT) @Override/*from w w w . j a va 2 s. com*/ public boolean onOptionsItemSelected(MenuItem item) { // Handle presses on the action bar items switch (item.getItemId()) { case R.id.action_start_selection: listener.startMultiSelect(); return true; case R.id.action_settings: Intent intentSettings = new Intent(getActivity(), SettingsActivity.class); startActivity(intentSettings); return true; case R.id.action_import: Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); intent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] { "text/plain", "text/html", "text/x-markdown" }); intent.setType("*/*"); try { getActivity().startActivityForResult(intent, MainActivity.IMPORT); } catch (ActivityNotFoundException e) { showToast(R.string.error_importing_notes); } return true; case R.id.action_about: DialogFragment aboutFragment = new AboutDialogFragment(); aboutFragment.show(getFragmentManager(), "about"); return true; default: return super.onOptionsItemSelected(item); } }
From source file:com.google.android.apps.muzei.gallery.GallerySettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gallery_activity); Toolbar appBar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(appBar);//from w w w . j a va2 s .c o m getSupportLoaderManager().initLoader(0, null, this); bindService(new Intent(this, GalleryArtSource.class).setAction(GalleryArtSource.ACTION_BIND_GALLERY), mServiceConnection, BIND_AUTO_CREATE); mPlaceholderDrawable = new ColorDrawable( ContextCompat.getColor(this, R.color.gallery_chosen_photo_placeholder)); mPhotoGridView = (RecyclerView) findViewById(R.id.photo_grid); DefaultItemAnimator itemAnimator = new DefaultItemAnimator(); itemAnimator.setSupportsChangeAnimations(false); mPhotoGridView.setItemAnimator(itemAnimator); setupMultiSelect(); final GridLayoutManager gridLayoutManager = new GridLayoutManager(GallerySettingsActivity.this, 1); mPhotoGridView.setLayoutManager(gridLayoutManager); final ViewTreeObserver vto = mPhotoGridView.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { int width = mPhotoGridView.getWidth() - mPhotoGridView.getPaddingStart() - mPhotoGridView.getPaddingEnd(); if (width <= 0) { return; } // Compute number of columns int maxItemWidth = getResources() .getDimensionPixelSize(R.dimen.gallery_chosen_photo_grid_max_item_size); int numColumns = 1; while (true) { if (width / numColumns > maxItemWidth) { ++numColumns; } else { break; } } int spacing = getResources().getDimensionPixelSize(R.dimen.gallery_chosen_photo_grid_spacing); mItemSize = (width - spacing * (numColumns - 1)) / numColumns; // Complete setup gridLayoutManager.setSpanCount(numColumns); mChosenPhotosAdapter.setHasStableIds(true); mPhotoGridView.setAdapter(mChosenPhotosAdapter); mPhotoGridView.getViewTreeObserver().removeOnGlobalLayoutListener(this); tryUpdateSelection(false); } }); ViewCompat.setOnApplyWindowInsetsListener(mPhotoGridView, new OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(final View v, final WindowInsetsCompat insets) { int gridSpacing = getResources().getDimensionPixelSize(R.dimen.gallery_chosen_photo_grid_spacing); ViewCompat.onApplyWindowInsets(v, insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft() + gridSpacing, gridSpacing, insets.getSystemWindowInsetRight() + gridSpacing, insets.getSystemWindowInsetBottom() + insets.getSystemWindowInsetTop() + gridSpacing + getResources().getDimensionPixelSize(R.dimen.gallery_fab_space))); return insets; } }); Button enableRandomImages = (Button) findViewById(R.id.gallery_enable_random); enableRandomImages.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { ActivityCompat.requestPermissions(GallerySettingsActivity.this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_STORAGE_PERMISSION); } }); Button permissionSettings = (Button) findViewById(R.id.gallery_edit_permission_settings); permissionSettings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", getPackageName(), null)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); mAddButton = findViewById(R.id.add_photos_button); mAddButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Use ACTION_OPEN_DOCUMENT by default for adding photos. // This allows us to use persistent URI permissions to access the underlying photos // meaning we don't need to use additional storage space and will pull in edits automatically // in addition to syncing deletions. // (There's a separate 'Import photos' option which uses ACTION_GET_CONTENT to support legacy apps) Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(intent, REQUEST_CHOOSE_PHOTOS); } }); }
From source file:com.cerema.cloud2.ui.fragment.OCFileListFragment.java
/** * registers {@link android.view.View.OnClickListener} and {@link android.view.View.OnLongClickListener} * on the Upload from App mini FAB for the linked action and {@link Toast} showing the underlying action. *///from w ww. ja v a 2 s .co m private void registerFabUploadFromAppListeners() { getFabUploadFromApp().setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent action = new Intent(Intent.ACTION_GET_CONTENT); action = action.setType("*/*").addCategory(Intent.CATEGORY_OPENABLE); //Intent.EXTRA_ALLOW_MULTIPLE is only supported on api level 18+, Jelly Bean if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) { action.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } getActivity().startActivityForResult( Intent.createChooser(action, getString(R.string.upload_chooser_title)), FileDisplayActivity.ACTION_SELECT_CONTENT_FROM_APPS); getFabMain().collapse(); recordMiniFabClick(); } }); getFabUploadFromApp().setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { Toast.makeText(getActivity(), R.string.actionbar_upload_from_apps, Toast.LENGTH_SHORT).show(); return true; } }); }
From source file:im.vector.activity.RoomActivity.java
/** * Launch the files selection intent/*from w w w .jav a 2 s . 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:mgks.os.webview.MainActivity.java
@SuppressLint({ "SetJavaScriptEnabled", "WrongViewCast" }) @Override//from w w w .j av a 2 s. c om protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.w("READ_PERM = ", Manifest.permission.READ_EXTERNAL_STORAGE); Log.w("WRITE_PERM = ", Manifest.permission.WRITE_EXTERNAL_STORAGE); //Prevent the app from being started again when it is still alive in the background if (!isTaskRoot()) { finish(); return; } setContentView(R.layout.activity_main); asw_view = findViewById(R.id.msw_view); final SwipeRefreshLayout pullfresh = findViewById(R.id.pullfresh); if (ASWP_PULLFRESH) { pullfresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { pull_fresh(); pullfresh.setRefreshing(false); } }); asw_view.getViewTreeObserver() .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { if (asw_view.getScrollY() == 0) { pullfresh.setEnabled(true); } else { pullfresh.setEnabled(false); } } }); } else { pullfresh.setRefreshing(false); pullfresh.setEnabled(false); } if (ASWP_PBAR) { asw_progress = findViewById(R.id.msw_progress); } else { findViewById(R.id.msw_progress).setVisibility(View.GONE); } asw_loading_text = findViewById(R.id.msw_loading_text); Handler handler = new Handler(); //Launching app rating request if (ASWP_RATINGS) { handler.postDelayed(new Runnable() { public void run() { get_rating(); } }, 1000 * 60); //running request after few moments } //Getting basic device information get_info(); //Getting GPS location of device if given permission if (ASWP_LOCATION && !check_permission(1)) { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, loc_perm); } get_location(); //Webview settings; defaults are customized for best performance WebSettings webSettings = asw_view.getSettings(); if (!ASWP_OFFLINE) { webSettings.setJavaScriptEnabled(ASWP_JSCRIPT); } webSettings.setSaveFormData(ASWP_SFORM); webSettings.setSupportZoom(ASWP_ZOOM); webSettings.setGeolocationEnabled(ASWP_LOCATION); webSettings.setAllowFileAccess(true); webSettings.setAllowFileAccessFromFileURLs(true); webSettings.setAllowUniversalAccessFromFileURLs(true); webSettings.setUseWideViewPort(true); webSettings.setDomStorageEnabled(true); asw_view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { return true; } }); asw_view.setHapticFeedbackEnabled(false); asw_view.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) { if (!check_permission(2)) { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE }, file_perm); } else { DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.setMimeType(mimeType); String cookies = CookieManager.getInstance().getCookie(url); request.addRequestHeader("cookie", cookies); request.addRequestHeader("User-Agent", userAgent); request.setDescription(getString(R.string.dl_downloading)); request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimeType)); request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(url, contentDisposition, mimeType)); DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); assert dm != null; dm.enqueue(request); Toast.makeText(getApplicationContext(), getString(R.string.dl_downloading2), Toast.LENGTH_LONG) .show(); } } }); if (Build.VERSION.SDK_INT >= 21) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark)); asw_view.setLayerType(View.LAYER_TYPE_HARDWARE, null); webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } else if (Build.VERSION.SDK_INT >= 19) { asw_view.setLayerType(View.LAYER_TYPE_HARDWARE, null); } asw_view.setVerticalScrollBarEnabled(false); asw_view.setWebViewClient(new Callback()); //Rendering the default URL aswm_view(ASWV_URL, false); asw_view.setWebChromeClient(new WebChromeClient() { //Handling input[type="file"] requests for android API 16+ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { if (ASWP_FUPLOAD) { asw_file_message = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType(ASWV_F_TYPE); if (ASWP_MULFILE) { i.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } startActivityForResult(Intent.createChooser(i, getString(R.string.fl_chooser)), asw_file_req); } } //Handling input[type="file"] requests for android API 21+ public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { if (check_permission(2) && check_permission(3)) { if (ASWP_FUPLOAD) { if (asw_file_path != null) { asw_file_path.onReceiveValue(null); } asw_file_path = filePathCallback; Intent takePictureIntent = null; if (ASWP_CAMUPLOAD) { takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(MainActivity.this.getPackageManager()) != null) { File photoFile = null; try { photoFile = create_image(); takePictureIntent.putExtra("PhotoPath", asw_cam_message); } catch (IOException ex) { Log.e(TAG, "Image file creation failed", ex); } if (photoFile != null) { asw_cam_message = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); if (!ASWP_ONLYCAM) { contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType(ASWV_F_TYPE); if (ASWP_MULFILE) { contentSelectionIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } } Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.fl_chooser)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, asw_file_req); } return true; } else { get_file(); return false; } } //Getting webview rendering progress @Override public void onProgressChanged(WebView view, int p) { if (ASWP_PBAR) { asw_progress.setProgress(p); if (p == 100) { asw_progress.setProgress(0); } } } // overload the geoLocations permissions prompt to always allow instantly as app permission was granted previously public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { if (Build.VERSION.SDK_INT < 23 || check_permission(1)) { // location permissions were granted previously so auto-approve callback.invoke(origin, true, false); } else { // location permissions not granted so request them ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, loc_perm); } } }); if (getIntent().getData() != null) { String path = getIntent().getDataString(); /* If you want to check or use specific directories or schemes or hosts Uri data = getIntent().getData(); String scheme = data.getScheme(); String host = data.getHost(); List<String> pr = data.getPathSegments(); String param1 = pr.get(0); */ aswm_view(path, false); } }
From source file:com.raspi.chatapp.ui.chatting.ChatActivity.java
public void sendLibraryImage(View view) { // hide the popup View v = findViewById(R.id.popup_layout); if (v != null) { v.setVisibility(View.GONE); attachPopup = false;//from w w w . ja v a 2 s . com } // when clicking attack the user should at first select an application to // choose the image with and then choose an image. // this intent is for getting the image Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT); getIntent.setType("image/*"); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) getIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); // and this for getting the application to get the image with Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); pickIntent.setType("image/*"); // and this finally is for opening the chooserIntent for opening the // getIntent for returning the image uri. Yep, thanks android Intent chooserIntent = Intent.createChooser(getIntent, getResources().getString(R.string.select_image)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { pickIntent }); startActivityForResult(chooserIntent, SEND_LIBRARY_IMAGE_REQUEST_CODE); // nope I don't want to be asked for a pwd when selected the image getSharedPreferences(Constants.PREFERENCES, 0).edit().putBoolean(Constants.PWD_REQUEST, false).apply(); }
From source file:com.krayzk9s.imgurholo.activities.MainActivity.java
private void displayUpload() { new AlertDialog.Builder(this).setTitle(R.string.dialog_upload_options_title) .setItems(R.array.upload_options, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { Intent intent;/*from w w w .j a va 2s . co m*/ MainActivity activity = MainActivity.this; switch (whichButton) { case 0: final EditText urlText = new EditText(activity); urlText.setSingleLine(); new AlertDialog.Builder(activity).setTitle(R.string.dialog_url_title).setView(urlText) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (urlText.getText() != null) { UrlAsync urlAsync = new UrlAsync(urlText.getText().toString(), apiCall); urlAsync.execute(); } } }).setNegativeButton(R.string.dialog_answer_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }) .show(); break; case 1: intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(Intent.createChooser(intent, "Select Picture"), 3); break; case 2: intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, 4); break; case 3: new AlertDialog.Builder(activity).setTitle(R.string.dialog_explanation_title) .setMessage(R.string.dialog_explanation_summary) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { //do nothing } }).show(); default: break; } } }).setNegativeButton(R.string.dialog_answer_cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Do nothing. } }).show(); }
From source file:com.google.android.apps.muzei.gallery.GallerySettingsActivity.java
private void requestGetContent(ActivityInfo info) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/*"); intent.setClassName(info.packageName, info.name); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(intent, REQUEST_CHOOSE_PHOTOS); }