List of usage examples for android.content Intent ACTION_SEND_MULTIPLE
String ACTION_SEND_MULTIPLE
To view the source code for android.content Intent ACTION_SEND_MULTIPLE.
Click Source Link
From source file:org.alfresco.mobile.android.application.activity.PublicDispatcherActivity.java
/** Called when the activity is first created. */ @Override//from www . ja va 2 s .co m public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); displayAsDialogActivity(); setContentView(R.layout.activitycompat_left_panel); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); if (toolbar != null) { setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setHomeButtonEnabled(true); } String action = getIntent().getAction(); if ((Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) && getFragment(UploadFormFragment.TAG) == null) { FragmentDisplayer.with(this).load(new UploadFormFragment()).back(false).animate(null) .into(FragmentDisplayer.PANEL_LEFT); return; } if (Intent.ACTION_VIEW.equals(action) && AlfrescoIntentAPI.SCHEME.equals(getIntent().getData().getScheme().toLowerCase())) { managePublicIntent(null); return; } if (PrivateIntent.ACTION_SYNCHRO_DISPLAY.equals(action)) { SyncFragment.with(this).mode(SyncFragment.MODE_PROGRESS).display(); return; } if (PrivateIntent.ACTION_PICK_FILE.equals(action)) { File f; if (getIntent().hasExtra(PrivateIntent.EXTRA_FOLDER)) { f = (File) getIntent().getExtras().getSerializable(PrivateIntent.EXTRA_FOLDER); FragmentDisplayer.with(this) .load(FileExplorerFragment.with(this).menuId(1).file(f).isShortCut(true) .mode(ListingModeFragment.MODE_PICK).createFragment()) .back(false).into(FragmentDisplayer.PANEL_LEFT); } } }
From source file:com.wit.android.support.content.intent.ShareIntent.java
/** *//*w ww . j a v a 2 s. co m*/ @Nullable @Override public Intent buildIntent() { if (TextUtils.isEmpty(mDataType)) { Log.e(TAG, "Can not to create SHARE intent. Missing MIME type."); return null; } final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType(mDataType); if (!TextUtils.isEmpty(mTitle)) { intent.putExtra(Intent.EXTRA_TITLE, mTitle); } if (!TextUtils.isEmpty(mContent)) { intent.putExtra(Intent.EXTRA_TEXT, mContent); } if (mUri != null) { intent.putExtra(Intent.EXTRA_STREAM, mUri); } else if (mUris != null) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, mUris); } return intent; }
From source file:at.wada811.utils.IntentUtils.java
/** * Intent???//from w w w .ja v a 2 s . co m * * @param intent * @param filePaths * @param mimeType * @return */ public static Intent addFiles(Intent intent, ArrayList<String> filePaths, String mimeType) { intent.setAction(Intent.ACTION_SEND_MULTIPLE); intent.setType(mimeType); ArrayList<Uri> uris = new ArrayList<Uri>(filePaths.size()); for (String filePath : filePaths) { uris.add(Uri.fromFile(new File(filePath))); } intent.putExtra(Intent.EXTRA_STREAM, uris); return intent; }
From source file:com.theelix.libreexplorer.ActionModeCallback.java
@Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { SparseBooleanArray checkedArray = listView.getCheckedItemPositions(); final List<File> selectedFiles = new ArrayList<>(); final ArrayList<Uri> selectedUris = new ArrayList<>(); for (int i = 0; i < listView.getCount(); i++) { if (checkedArray.get(i)) { selectedFiles.add((File) listView.getItemAtPosition(i)); selectedUris.add(android.net.Uri.fromFile((File) listView.getItemAtPosition(i))); }/*from w w w .ja v a2 s .co m*/ } switch (item.getItemId()) { case R.id.toolbar_menu_copy: FileManager.prepareCopy(selectedFiles.toArray(new File[selectedFiles.size()])); break; case R.id.toolbar_menu_cut: FileManager.prepareCut(selectedFiles.toArray(new File[selectedFiles.size()])); break; case R.id.toolbar_menu_delete: AlertDialog.Builder builder = new AlertDialog.Builder(mContext); if (selectedFiles.size() > 1) { builder.setMessage(mContext.getString(R.string.delete_dialog_multiple) + " " + selectedFiles.size() + " " + mContext.getString(R.string.delete_dialog_items) + "?"); } else builder.setMessage(mContext.getString(R.string.delete_dialog_single)); builder.setPositiveButton(mContext.getString(R.string.dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { DeleteTask task = new DeleteTask(mContext, selectedFiles.toArray(new File[selectedFiles.size()])); task.execute(); } }); builder.setNegativeButton(mContext.getString(R.string.dialog_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.show(); break; case R.id.toolbar_menu_rename: DialogFragment renameDialog = new RenameDialog(); ((RenameDialog) renameDialog).setSelectedFiles(selectedFiles.toArray()); renameDialog.show(((FileManagerActivity) mContext).getSupportFragmentManager(), "rename_dialog"); break; case R.id.toolbar_menu_details: DialogFragment detailsDialog = new DetailsDialog(); ((DetailsDialog) detailsDialog).setTargetFile(selectedFiles.get(0)); detailsDialog.show(((FileManagerActivity) mContext).getSupportFragmentManager(), "details_dialog"); break; case R.id.toolbar_menu_share: Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, selectedUris); shareIntent.setType("*/*"); mContext.startActivity(Intent.createChooser(shareIntent, "Share to...")); break; } mode.finish(); return true; }
From source file:com.cerema.cloud2.ui.activity.LogHistoryActivity.java
/** * Start activity for sending email with logs attached *//*from w ww. j av a2 s . c o m*/ private void sendMail() { // For the moment we need to consider the possibility that setup.xml // does not include the "mail_logger" entry. This block prevents that // compilation fails in this case. String emailAddress; try { Class<?> stringClass = R.string.class; Field mailLoggerField = stringClass.getField("mail_logger"); int emailAddressId = (Integer) mailLoggerField.get(null); emailAddress = getString(emailAddressId); } catch (Exception e) { emailAddress = ""; } ArrayList<Uri> uris = new ArrayList<Uri>(); // Convert from paths to Android friendly Parcelable Uri's for (String file : Log_OC.getLogFileNames()) { File logFile = new File(mLogPath, file); if (logFile.exists()) { uris.add(Uri.fromFile(logFile)); } } Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.putExtra(Intent.EXTRA_EMAIL, emailAddress); String subject = String.format(getString(R.string.log_send_mail_subject), getString(R.string.app_name)); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setType(MAIL_ATTACHMENT_TYPE); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); try { startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(this, getString(R.string.log_send_no_mail_app), Toast.LENGTH_LONG).show(); Log_OC.i(TAG, "Could not find app for sending log history."); } }
From source file:com.yahala.ui.LaunchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); XMPPManager.foreground = false;//from ww w . j a va 2 s.c o m ApplicationLoader.postInitApplication(); this.setTheme(R.style.Theme_TMessages); try { openAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_in); closeAnimation = AnimationUtils.loadAnimation(this, R.anim.scale_out); } catch (Exception e) { FileLog.e("yahala", e); } // getWindow().setBackgroundDrawableResource(R.drawable.transparent); getWindow().setFormat(PixelFormat.RGB_888); if (!UserConfig.clientActivated) { Intent intent = getIntent(); if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction()) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) { finish(); return; } Intent intent2 = new Intent(this, IntroActivity.class); startActivity(intent2); finish(); return; } else { SecurePreferences preferences = new SecurePreferences(this, "preferences", "Blacktow@111", true); String locked = preferences.getString("locked", "false"); String lockedAuthenticated = preferences.getString("clientAuthenticated", "false"); if (locked.equals("true") && lockedAuthenticated.equals("false") && !getIntent().getAction().startsWith("com.yahala.openchat")) { Intent intent = getIntent(); if (intent != null && intent.getAction() != null && (Intent.ACTION_SEND.equals(intent.getAction()) || intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE))) { finish(); return; } Intent intent2 = new Intent(this, UnlockActivity.class); startActivity(intent2); finish(); return; } preferences.put("clientAuthenticated", "false"); //String user = preferences.getString("userId"); } int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { OSUtilities.statusBarHeight = getResources().getDimensionPixelSize(resourceId); } NotificationCenter.getInstance().postNotificationName(702, this); // currentConnectionState = ConnectionsManager.getInstance().connectionState; for (BaseFragment fragment : ApplicationLoader.fragmentsStack) { if (fragment.fragmentView != null) { ViewGroup parent = (ViewGroup) fragment.fragmentView.getParent(); if (parent != null) { parent.removeView(fragment.fragmentView); } fragment.fragmentView = null; } fragment.parentActivity = this; } setContentView(R.layout.application_layout); NotificationCenter.getInstance().addObserver(this, 1234); NotificationCenter.getInstance().addObserver(this, XMPPManager.connectionStateDidChanged); NotificationCenter.getInstance().addObserver(this, XMPPManager.currentUserPresenceDidChanged); //NotificationCenter.getInstance().addObserver(this, 701); NotificationCenter.getInstance().addObserver(this, 702); /* NotificationCenter.getInstance().addObserver(this, 703);*/ // NotificationCenter.getInstance().addObserver(this, XmppManager.connectionSuccessful); // NotificationCenter.getInstance().addObserver(this, 1003); // NotificationCenter.getInstance().addObserver(this, GalleryImageViewer.needShowAllMedia); ////getSupportActionBar().setLogo(R.drawable.ab_icon_fixed2); /* statusView = getLayoutInflater().inflate(R.layout.updating_state_layout, null); statusBackground = statusView.findViewById(R.id.back_button_background); backStatusButton = statusView.findViewById(R.id.back_button); containerView = findViewById(R.id.container); statusText = (TextView)statusView.findViewById(R.id.status_text);*/ connectionStatusLayout = (LinearLayout) findViewById(R.id.connection_status_layout); connectionStatus = (TextView) findViewById(R.id.connection_status); /* statusBackground.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (ApplicationLoader.fragmentsStack.size() > 1) { onBackPressed(); } } });*/ if (XMPPManager.getInstance().connectionState == ConnectionState.ONLINE) { connectionStatusLayout.setVisibility(View.GONE); } if (ApplicationLoader.fragmentsStack.isEmpty()) { MainActivity fragment = new MainActivity(); fragment.onFragmentCreate(); ApplicationLoader.fragmentsStack.add(fragment); } // savedInstanceState != null ===>>> possible orientation change /* if (savedInstanceState != null && savedInstanceState.containsKey("StatusLayoutIsShowing")) { connectionStatusLayout.setVisibility(View.VISIBLE); } else { connectionStatusLayout.setVisibility(View.GONE); }*/ handleIntent(getIntent(), false, savedInstanceState != null); }
From source file:com.synox.android.ui.activity.LogHistoryActivity.java
/** * Start activity for sending email with logs attached *///from ww w .j av a 2s . c om private void sendMail() { // For the moment we need to consider the possibility that setup.xml // does not include the "mail_logger" entry. This block prevents that // compilation fails in this case. String emailAddress; try { Class<?> stringClass = R.string.class; Field mailLoggerField = stringClass.getField("mail_logger"); int emailAddressId = (Integer) mailLoggerField.get(null); emailAddress = getString(emailAddressId); } catch (Exception e) { emailAddress = ""; } ArrayList<Uri> uris = new ArrayList<>(); // Convert from paths to Android friendly Parcelable Uri's for (String file : Log_OC.getLogFileNames()) { File logFile = new File(mLogPath, file); if (logFile.exists()) { uris.add(Uri.fromFile(logFile)); } } Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE); intent.putExtra(Intent.EXTRA_EMAIL, emailAddress); String subject = String.format(getString(R.string.log_send_mail_subject), getString(R.string.app_name)); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setType(MAIL_ATTACHMENT_TYPE); intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); try { startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(this, getString(R.string.log_send_no_mail_app), Toast.LENGTH_LONG).show(); Log_OC.i(TAG, "Could not find app for sending log history."); } }
From source file:com.asksven.betterbatterystats.ShareDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the Builder class for convenient dialog construction //ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), android.R.style.Theme_Holo_Light_Dialog); ContextThemeWrapper context = new ContextThemeWrapper(getActivity(), BaseActivity.getTheme(getActivity())); AlertDialog.Builder builder = new AlertDialog.Builder(context); final ArrayList<Integer> selectedSaveActions = new ArrayList<Integer>(); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); boolean saveAsText = sharedPrefs.getBoolean("save_as_text", true); boolean saveAsJson = sharedPrefs.getBoolean("save_as_json", false); boolean saveLogcat = sharedPrefs.getBoolean("save_logcat", false); boolean saveDmesg = sharedPrefs.getBoolean("save_dmesg", false); final String m_refFromName = ""; final String m_refToName = ""; if (saveAsText) { selectedSaveActions.add(0);/*ww w . j a v a 2s. c o m*/ } if (saveAsJson) { selectedSaveActions.add(1); } if (saveLogcat) { selectedSaveActions.add(2); } if (saveDmesg) { selectedSaveActions.add(3); } builder.setTitle("Title"); builder.setMultiChoiceItems(R.array.saveAsLabels, new boolean[] { saveAsText, saveAsJson, saveLogcat, saveDmesg }, new DialogInterface.OnMultiChoiceClickListener() { @Override public void onClick(DialogInterface dialog, int which, boolean isChecked) { if (isChecked) { // If the user checked the item, add it to the // selected items selectedSaveActions.add(which); } else if (selectedSaveActions.contains(which)) { // Else, if the item is already in the array, // remove it selectedSaveActions.remove(Integer.valueOf(which)); } } }) // Set the action buttons .setPositiveButton(R.string.label_button_share, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { ArrayList<Uri> attachements = new ArrayList<Uri>(); Reference myReferenceFrom = ReferenceStore.getReferenceByName(m_refFromName, getActivity()); Reference myReferenceTo = ReferenceStore.getReferenceByName(m_refToName, getActivity()); Reading reading = new Reading(getActivity(), myReferenceFrom, myReferenceTo); // save as text is selected if (selectedSaveActions.contains(0)) { attachements.add(reading.writeToFileText(getActivity())); } // save as JSON if selected if (selectedSaveActions.contains(1)) { attachements.add(reading.writeToFileJson(getActivity())); } // save logcat if selected if (selectedSaveActions.contains(2)) { attachements.add(StatsProvider.getInstance(getActivity()).writeLogcatToFile()); } // save dmesg if selected if (selectedSaveActions.contains(3)) { attachements.add(StatsProvider.getInstance(getActivity()).writeDmesgToFile()); } if (!attachements.isEmpty()) { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND_MULTIPLE); shareIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, attachements); shareIntent.setType("text/*"); startActivity(Intent.createChooser(shareIntent, "Share info to..")); } } }).setNeutralButton(R.string.label_button_save, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { Reference myReferenceFrom = ReferenceStore.getReferenceByName(m_refFromName, getActivity()); Reference myReferenceTo = ReferenceStore.getReferenceByName(m_refToName, getActivity()); Reading reading = new Reading(getActivity(), myReferenceFrom, myReferenceTo); // save as text is selected // save as text is selected if (selectedSaveActions.contains(0)) { reading.writeToFileText(getActivity()); } // save as JSON if selected if (selectedSaveActions.contains(1)) { reading.writeToFileJson(getActivity()); } // save logcat if selected if (selectedSaveActions.contains(2)) { StatsProvider.getInstance(getActivity()).writeLogcatToFile(); } // save dmesg if selected if (selectedSaveActions.contains(3)) { StatsProvider.getInstance(getActivity()).writeDmesgToFile(); } } }).setNegativeButton(R.string.label_button_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { // do nothing } }); // Create the AlertDialog object and return it return builder.create(); }
From source file:com.doplgangr.secrecy.views.FileViewer.java
void sendMultiple(final ArrayList<FilesListFragment.DecryptArgHolder> args) { new Thread(new Runnable() { @Override//from w w w.ja v a 2 s . co m public void run() { ArrayList<Uri> uris = new ArrayList<Uri>(); Set<String> mimes = new HashSet<String>(); MimeTypeMap myMime = MimeTypeMap.getSingleton(); for (FilesListFragment.DecryptArgHolder arg : args) { File tempFile = getFile(arg.encryptedFile, arg.onFinish); //File specified is not invalid if (tempFile != null) { if (tempFile.getParentFile().equals(Storage.getTempFolder())) tempFile = new java.io.File(Storage.getTempFolder(), tempFile.getName()); uris.add(OurFileProvider.getUriForFile(context, OurFileProvider.FILE_PROVIDER_AUTHORITY, tempFile)); mimes.add(myMime.getMimeTypeFromExtension(arg.encryptedFile.getType())); } } if (uris.size() == 0 || mimes.size() == 0) return; Intent newIntent; if (uris.size() == 1) { newIntent = new Intent(Intent.ACTION_SEND); newIntent.putExtra(Intent.EXTRA_STREAM, uris.get(0)); } else { newIntent = new Intent(Intent.ACTION_SEND_MULTIPLE); newIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); } if (mimes.size() > 1) newIntent.setType("text/plain"); //Mixed filetypes else newIntent.setType(new ArrayList<String>(mimes).get(0)); newIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); Intent chooserIntent = generateCustomChooserIntent(newIntent, uris); try { startActivity(Intent.createChooser(chooserIntent, CustomApp.context.getString(R.string.Dialog__send_file))); FilesActivity.onPauseDecision.startActivity(); } catch (android.content.ActivityNotFoundException e) { Util.toast(context, CustomApp.context.getString(R.string.Error__no_activity_view), Toast.LENGTH_LONG); FilesActivity.onPauseDecision.finishActivity(); } } }).start(); }
From source file:org.exoplatform.shareextension.ShareActivity.java
private boolean isIntentCorrect() { Intent intent = getIntent();/*from ww w. jav a2s . co m*/ String action = intent.getAction(); String type = intent.getType(); mMultiFlag = Intent.ACTION_SEND_MULTIPLE.equals(action); return ((Intent.ACTION_SEND.equals(action) || mMultiFlag) && type != null); }