List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:com.example.admin.news.mvp.ui.activities.NewsDetailActivity.java
private void share() { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share)); intent.putExtra(Intent.EXTRA_TEXT, getShareContents()); startActivity(Intent.createChooser(intent, getTitle())); }
From source file:com.deliciousdroid.activity.BrowseBookmarks.java
public void onBookmarkShare(Bookmark b) { if (b != null) { Intent sendIntent = IntentHelper.SendBookmark(b.getUrl(), b.getDescription()); startActivity(Intent.createChooser(sendIntent, getString(R.string.share_chooser_title))); }// w ww . j av a 2s . c o m }
From source file:com.example.ishita.administrativeapp.AttendantActivity.java
@SuppressWarnings("StatementWithEmptyBody") @Override/*from w w w . ja va2s .c o m*/ public boolean onNavigationItemSelected(MenuItem item) { int id = item.getItemId(); if (id == R.id.profile) { /* Intent launch_profile= new Intent(getApplicationContext(),Profile.class); launch_profile.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); launch_profile.putExtra("EXIT",true); startActivity(launch_profile);*/ } else if (id == R.id.about) { /* AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(String.format("%1$s", getString(R.string.app_name))); builder.setMessage(getResources().getText(R.string.about_text)); builder.setPositiveButton("OK", null); builder.setIcon(R.mipmap.ic_launcher); AlertDialog welcomeAlert = builder.create(); welcomeAlert.show(); ((TextView) welcomeAlert.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());*/ } else if (id == R.id.contributors) { /* AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(String.format("%1$s", getString(R.string.contributors))); builder.setMessage(getResources().getText(R.string.contributors_text)); builder.setPositiveButton("OK", null); //builder.setIcon(R.mipmap.nimbus_icon); AlertDialog welcomeAlert = builder.create(); welcomeAlert.show(); ((TextView) welcomeAlert.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());*/ } else if (id == R.id.bug) { Intent intent = new Intent(Intent.ACTION_SENDTO); String uriText = "mailto:" + Uri.encode("ishitathakur@gmail.com") + "?subject=" + Uri.encode("Reporting A Bug/Feedback") + "&body=" + Uri.encode( "Hello, Ishita \nI want to report a bug/give feedback corresponding to the app EOutPass.\n.....\n\n-Your name"); Uri uri = Uri.parse(uriText); intent.setData(uri); startActivity(Intent.createChooser(intent, "Send Email")); } else if (id == R.id.licenses) { /* AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle(String.format("%1$s", getString(R.string.open_source_licenses))); builder.setMessage(getResources().getText(R.string.licenses_text)); builder.setPositiveButton("OK", null); //builder.setIcon(R.mipmap.nimbus_icon); AlertDialog welcomeAlert = builder.create(); welcomeAlert.show(); ((TextView) welcomeAlert.findViewById(android.R.id.message)).setMovementMethod(LinkMovementMethod.getInstance());*/ } return true; }
From source file:fr.simon.marquis.secretcodes.ui.MainActivity.java
private void sendEmail(ArrayList<SecretCode> secretCodes) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.extra_email) }); i.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.extra_subject)); i.putExtra(Intent.EXTRA_TEXT, generateEmailBody(secretCodes)); i.putExtra(Intent.EXTRA_STREAM, ExportContentProvider.CONTENT_URI); startActivity(Intent.createChooser(i, null)); }
From source file:com.code.android.vibevault.SearchScreen.java
/** Handle user's long-click selection. * *//*from www .j av a 2s .c o m*/ @Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo menuInfo = (AdapterContextMenuInfo) item.getMenuInfo(); if (menuInfo != null) { ArchiveShowObj selShow = (ArchiveShowObj) searchList.getAdapter().getItem(menuInfo.position); switch (item.getItemId()) { case VibeVault.EMAIL_LINK: final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Great show on archive.org: " + selShow.getArtistAndTitle()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hey,\n\nYou should listen to " + selShow.getArtistAndTitle() + ". You can find it here: " + selShow.getShowURL() + "\n\nSent using VibeVault for Android."); startActivity(Intent.createChooser(emailIntent, "Send mail...")); return true; case VibeVault.SHOW_INFO: AlertDialog.Builder ad = new AlertDialog.Builder(this); ad.setTitle("Show Info"); View v = LayoutInflater.from(this).inflate(R.layout.scrollable_dialog, null); ((TextView) v.findViewById(R.id.DialogText)).setText(selShow.getSource()); ad.setPositiveButton("Okay.", new android.content.DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { } }); ad.setView(v); ad.show(); return true; case (VibeVault.ADD_TO_FAVORITE_LIST): VibeVault.db.insertFavoriteShow(selShow); return true; default: return false; } } return false; }
From source file:com.eyekabob.util.EyekabobHelper.java
public static void launchEmail(Activity activity) { Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("plain/text"); String to[] = { "philj21@yahoo.com", "adam.sill01@gmail.com", "coffbr01@gmail.com" }; emailIntent.putExtra(Intent.EXTRA_EMAIL, to); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Eyekabob Advertising"); String label = activity.getResources().getString(R.string.write_email); activity.startActivity(Intent.createChooser(emailIntent, label)); }
From source file:name.zurell.kirk.apps.android.rhetolog.RhetologApplication.java
/** Called when a session detail view asks to send session results somewhere. * Generates a link to the session report Uri, and lets the remote program read from it. * The {@link RhetologContentProvider} generates the result file on demand. * /*from w w w.java 2 s . co m*/ * */ @Override public void onSessionSend(Context context, Uri session) { // Send to the program selected by the chooser below. Intent sendSession = new Intent(Intent.ACTION_SEND); // Permit to read from Rhetolog URIs. sendSession.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); // Note type of send as report. sendSession.setType(RhetologContract.RHETOLOG_TYPE_SESSION_REPORT); sendSession.putExtra(Intent.EXTRA_SUBJECT, "Sending session " + session); // Send text as text. sendSession.putExtra(Intent.EXTRA_TEXT, reportForSession(session)); // Send text as URI to be read. sendSession.putExtra(Intent.EXTRA_STREAM, Uri.parse(RhetologContract.SESSIONSREPORT + "/" + session.getLastPathSegment())); // Permit user to choose target of send. context.startActivity(Intent.createChooser(sendSession, "Send session results")); }
From source file:com.door43.translationstudio.ui.dialogs.BackupDialog.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE); v = inflater.inflate(R.layout.dialog_backup, container, false); // get target translation to backup Bundle args = getArguments();/*from ww w .ja v a 2s. c o m*/ if (args != null && args.containsKey(ARG_TARGET_TRANSLATION_ID)) { String targetTranslationId = args.getString(ARG_TARGET_TRANSLATION_ID, null); targetTranslation = App.getTranslator().getTargetTranslation(targetTranslationId); if (targetTranslation == null) { throw new InvalidParameterException( "The target translation '" + targetTranslationId + "' is invalid"); } } else { throw new InvalidParameterException("The target translation id was not specified"); } targetTranslation.setDefaultContributor(App.getProfile().getNativeSpeaker()); mBackupToCloudButton = (LinearLayout) v.findViewById(R.id.backup_to_cloud); LinearLayout exportProjectButton = (LinearLayout) v.findViewById(R.id.backup_to_sd); Button backupToAppButton = (Button) v.findViewById(R.id.backup_to_app); Button backupToDeviceButton = (Button) v.findViewById(R.id.backup_to_device); LinearLayout exportToPDFButton = (LinearLayout) v.findViewById(R.id.export_to_pdf); LinearLayout exportToUsfmButton = (LinearLayout) v.findViewById(R.id.export_to_usfm); Button logout = (Button) v.findViewById(R.id.logout_button); logout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { App.setProfile(null); Intent logoutIntent = new Intent(getActivity(), ProfileActivity.class); startActivity(logoutIntent); } }); final String filename = targetTranslation.getId() + "." + Translator.ARCHIVE_EXTENSION; initProgressWatcher(R.string.backup); if (savedInstanceState != null) { // check if returning from device alias dialog settingDeviceAlias = savedInstanceState.getBoolean(STATE_SETTING_DEVICE_ALIAS, false); mDialogShown = eDialogShown .fromInt(savedInstanceState.getInt(STATE_DIALOG_SHOWN, eDialogShown.NONE.getValue())); mAccessFile = savedInstanceState.getString(STATE_ACCESS_FILE, null); mDialogMessage = savedInstanceState.getString(STATE_DIALOG_MESSAGE, null); isOutputToDocumentFile = savedInstanceState.getBoolean(STATE_OUTPUT_TO_DOCUMENT_FILE, false); mDestinationFolderUri = Uri.parse(savedInstanceState.getString(STATE_OUTPUT_FOLDER_URI, "")); restoreDialogs(); } Button dismissButton = (Button) v.findViewById(R.id.dismiss_button); dismissButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); backupToDeviceButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO: 11/18/2015 eventually we need to support bluetooth as well as an adhoc network showDeviceNetworkAliasDialog(); } }); // backup buttons mBackupToCloudButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (App.isNetworkAvailable()) { // make sure we have a gogs user if (App.getProfile().gogsUser == null) { showDoor43LoginDialog(); return; } doPullTargetTranslationTask(targetTranslation, MergeStrategy.RECURSIVE); } else { showNoInternetDialog(); // replaced snack popup which could be hidden behind dialog } } }); exportToPDFButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { PrintDialog printDialog = new PrintDialog(); Bundle printArgs = new Bundle(); printArgs.putString(PrintDialog.ARG_TARGET_TRANSLATION_ID, targetTranslation.getId()); printDialog.setArguments(printArgs); showDialogFragment(printDialog, PrintDialog.TAG); } }); exportProjectButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { doSelectDestinationFolder(false); } }); exportToUsfmButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { doSelectDestinationFolder(true); } }); if (targetTranslation.isObsProject()) { LinearLayout exportToUsfmSeparator = (LinearLayout) v.findViewById(R.id.export_to_usfm_separator); exportToUsfmSeparator.setVisibility(View.GONE); exportToUsfmButton.setVisibility(View.GONE); } backupToAppButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { File exportFile = new File(App.getSharingDir(), filename); try { App.getTranslator().exportArchive(targetTranslation, exportFile); } catch (Exception e) { Logger.e(TAG, "Failed to export the target translation " + targetTranslation.getId(), e); } if (exportFile.exists()) { Uri u = FileProvider.getUriForFile(getActivity(), "com.door43.translationstudio.fileprovider", exportFile); Intent i = new Intent(Intent.ACTION_SEND); i.setType("application/zip"); i.putExtra(Intent.EXTRA_STREAM, u); startActivity(Intent.createChooser(i, "Email:")); } else { Snackbar snack = Snackbar.make(getActivity().findViewById(android.R.id.content), R.string.translation_export_failed, Snackbar.LENGTH_LONG); ViewUtil.setSnackBarTextColor(snack, getResources().getColor(R.color.light_primary_text)); snack.show(); } } }); // connect to existing tasks PullTargetTranslationTask pullTask = (PullTargetTranslationTask) TaskManager .getTask(PullTargetTranslationTask.TASK_ID); RegisterSSHKeysTask keysTask = (RegisterSSHKeysTask) TaskManager.getTask(RegisterSSHKeysTask.TASK_ID); CreateRepositoryTask repoTask = (CreateRepositoryTask) TaskManager.getTask(CreateRepositoryTask.TASK_ID); PushTargetTranslationTask pushTask = (PushTargetTranslationTask) TaskManager .getTask(PushTargetTranslationTask.TASK_ID); ExportProjectTask projectExportTask = (ExportProjectTask) TaskManager.getTask(ExportProjectTask.TASK_ID); ExportToUsfmTask usfmExportTask = (ExportToUsfmTask) TaskManager.getTask(ExportToUsfmTask.TASK_ID); if (pullTask != null) { taskWatcher.watch(pullTask); } else if (keysTask != null) { taskWatcher.watch(keysTask); } else if (repoTask != null) { taskWatcher.watch(repoTask); } else if (pushTask != null) { taskWatcher.watch(pushTask); } else if (projectExportTask != null) { taskWatcher.watch(projectExportTask); } else if (usfmExportTask != null) { taskWatcher.watch(usfmExportTask); } return v; }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.PostFragment.java
/** * Displays dialog and either launches camera or gallery * /*from w w w . j av a 2 s. c o m*/ * @param view * the AttachPhoto button in postThreadFragment. */ public void attachImage(View view) { if (view.getId() == R.id.attach_image_button) { AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity()); dialog.setTitle(R.string.attach_image_title); dialog.setMessage(R.string.attach_image_dialog); dialog.setPositiveButton("Gallery", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { FavouritesFragment favFrag = (FavouritesFragment) getParentFragment(); boolean fromFav; if (favFrag != null) { fromFav = true; } else { fromFav = false; } Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); if (fromFav == true) { arg0.dismiss(); getParentFragment().startActivityForResult(Intent.createChooser(intent, "Test"), ImageHelper.REQUEST_GALLERY); } else { arg0.dismiss(); startActivityForResult(Intent.createChooser(intent, "Test"), ImageHelper.REQUEST_GALLERY); } } }); dialog.setNegativeButton("Camera", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { FavouritesFragment favFrag = (FavouritesFragment) getParentFragment(); boolean fromFav; if (favFrag != null) { fromFav = true; } else { fromFav = false; } Intent intent = new Intent(); intent.setAction(MediaStore.ACTION_IMAGE_CAPTURE); try { imageFile = ImageHelper.createImageFile(); intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile)); if (fromFav == true) { arg0.dismiss(); getParentFragment().startActivityForResult(Intent.createChooser(intent, "Test"), ImageHelper.REQUEST_CAMERA); } else { arg0.dismiss(); startActivityForResult(Intent.createChooser(intent, "Test"), ImageHelper.REQUEST_CAMERA); } } catch (IOException e) { e.printStackTrace(); } } }); dialog.show(); } }
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 www . j a va2 s. com*/ 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; } }); }