List of usage examples for android.content Intent ACTION_SEND
String ACTION_SEND
To view the source code for android.content Intent ACTION_SEND.
Click Source Link
From source file:com.richtodd.android.quiltdesign.app.BlockEditActivity.java
@Override public void onShareOptionsPositiveClick(DialogFragment dialog, RenderStyles renderStyle, RenderFormats renderFormat, String intentAction) throws Exception { Uri uriFile;/*from w w w . j a v a2s . c om*/ String type; switch (renderFormat) { case Bitmap: uriFile = saveBitmap(renderStyle); type = "image/png"; break; case PDF: uriFile = savePDF(renderStyle); type = "application/pdf"; break; case QuiltDesign: uriFile = saveQuiltDesign(); type = "application/vnd.richtodd.quiltdesign"; break; default: throw new IllegalArgumentException("Unknown render format " + renderFormat); } Intent intent = new Intent(intentAction); if (intentAction.equals(Intent.ACTION_SEND)) { intent.putExtra(Intent.EXTRA_STREAM, uriFile); intent.setType(type); startActivity(Intent.createChooser(intent, "Share With")); } else { intent.setDataAndType(uriFile, type); startActivity(Intent.createChooser(intent, "View With")); } }
From source file:com.app.uafeed.fragment.EntryFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (mEntriesIds != null) { Activity activity = getActivity(); switch (item.getItemId()) { case R.id.menu_star: { mFavorite = !mFavorite;//from w w w . ja va 2 s. c o m if (mFavorite) { item.setTitle(R.string.menu_unstar).setIcon(R.drawable.rating_important); } else { item.setTitle(R.string.menu_star).setIcon(R.drawable.rating_not_important); } final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread() { @Override public void run() { ContentValues values = new ContentValues(); values.put(EntryColumns.IS_FAVORITE, mFavorite ? 1 : 0); ContentResolver cr = MainApplication.getContext().getContentResolver(); cr.update(uri, values, null, null); // Update the cursor Cursor updatedCursor = cr.query(uri, null, null, null, null); updatedCursor.moveToFirst(); mEntryPagerAdapter.setUpdatedCursor(mCurrentPagerPos, updatedCursor); } }.start(); break; } case R.id.menu_share: { Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); String link = cursor.getString(mLinkPos); if (link != null) { String title = cursor.getString(mTitlePos); startActivity(Intent.createChooser( new Intent(Intent.ACTION_SEND).putExtra(Intent.EXTRA_SUBJECT, title) .putExtra(Intent.EXTRA_TEXT, link).setType(Constants.MIMETYPE_TEXT_PLAIN), getString(R.string.menu_share))); } break; } case R.id.menu_full_screen: { toggleFullScreen(); break; } case R.id.menu_copy_clipboard: { Cursor cursor = mEntryPagerAdapter.getCursor(mCurrentPagerPos); String link = cursor.getString(mLinkPos); ClipboardManager clipboard = (ClipboardManager) activity .getSystemService(Context.CLIPBOARD_SERVICE); ClipData clip = ClipData.newPlainText("Copied Text", link); clipboard.setPrimaryClip(clip); Toast.makeText(activity, R.string.copied_clipboard, Toast.LENGTH_SHORT).show(); break; } case R.id.menu_mark_as_unread: { final Uri uri = ContentUris.withAppendedId(mBaseUri, mEntriesIds[mCurrentPagerPos]); new Thread() { @Override public void run() { ContentResolver cr = MainApplication.getContext().getContentResolver(); cr.update(uri, FeedData.getUnreadContentValues(), null, null); } }.start(); activity.finish(); break; } } } return true; }
From source file:com.carlrice.reader.activity.EditFeedActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { UiUtils.setPreferenceTheme(this); super.onCreate(savedInstanceState); setContentView(R.layout.activity_feed_edit); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from w w w. ja v a 2s . c om*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); setResult(RESULT_CANCELED); Intent intent = getIntent(); mTabHost = (TabHost) findViewById(R.id.tabHost); mNameEditText = (EditText) findViewById(R.id.feed_title); mUrlEditText = (EditText) findViewById(R.id.feed_url); mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext); mFiltersListView = (ListView) findViewById(android.R.id.list); View tabWidget = findViewById(android.R.id.tabs); View buttonLayout = findViewById(R.id.button_layout); mTabHost.setup(); mTabHost.addTab(mTabHost.newTabSpec("feedTab").setIndicator(getString(R.string.tab_feed_title)) .setContent(R.id.feed_tab)); mTabHost.addTab(mTabHost.newTabSpec("filtersTab").setIndicator(getString(R.string.tab_filters_title)) .setContent(R.id.filters_tab)); mTabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() { @Override public void onTabChanged(String s) { invalidateOptionsMenu(); } }); if (savedInstanceState != null) { mTabHost.setCurrentTab(savedInstanceState.getInt(STATE_CURRENT_TAB)); } if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) { setTitle(R.string.new_feed_title); tabWidget.setVisibility(View.GONE); if (intent.hasExtra(Intent.EXTRA_TEXT)) { mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT)); } } else if (intent.getAction().equals(Intent.ACTION_EDIT)) { setTitle(R.string.edit_feed_title); buttonLayout.setVisibility(View.GONE); mFiltersCursorAdapter = new FiltersCursorAdapter(this, Constants.EMPTY_CURSOR); mFiltersListView.setAdapter(mFiltersCursorAdapter); mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { startSupportActionMode(mFilterActionModeCallback); mFiltersCursorAdapter.setSelectedFilter(position); mFiltersListView.invalidateViews(); return true; } }); getLoaderManager().initLoader(0, null, this); if (savedInstanceState == null) { Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null); if (cursor.moveToNext()) { mNameEditText.setText(cursor.getString(0)); mUrlEditText.setText(cursor.getString(1)); mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1); cursor.close(); } else { cursor.close(); Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show(); finish(); } } } }
From source file:com.apotheosis.acceleration.monitor.MainMenuActivity.java
private void setUpListView() { ListView lv = (ListView) findViewById(R.id.fileList); List<String> fileNames = FileUtilities.getFileList(); if (fileNames != null) { FileListAdapter listAdapter = new FileListAdapter(this); lv.setAdapter(listAdapter);// w w w. j a v a2s . co m lv.setTextFilterEnabled(true); lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View v, int position, long id) { DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.mainDrawerLayout); boolean isDrawerOpen = drawerLayout.isDrawerOpen(findViewById(R.id.side_drawer)); if (isDrawerOpen) drawerLayout.closeDrawers(); new LoadData(TimeXYZDataPackage.DataType.ACCELERATION, MainMenuActivity.this, parent.getAdapter().getItem(position).toString()).execute((Void[]) null); } }); lv.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) { final String fileName = parent.getAdapter().getItem(position).toString(); final AlertDialog.Builder optionsMenu = new AlertDialog.Builder(MainMenuActivity.this); optionsMenu.setItems(new String[] { "Open Acceleration Graph", "Open Raw Data", "Share Data", "Delete Data", "Cancel" }, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { DrawerLayout drawerLayout = (DrawerLayout) findViewById(R.id.mainDrawerLayout); boolean isDrawerOpen = drawerLayout .isDrawerOpen(findViewById(R.id.side_drawer)); Intent i; Tracker tracker; switch (which) { case 0: dialog.dismiss(); if (isDrawerOpen) drawerLayout.closeDrawers(); new LoadData(TimeXYZDataPackage.DataType.ACCELERATION, MainMenuActivity.this, fileName).execute((Void[]) null); break; case 1: if (isDrawerOpen) drawerLayout.closeDrawers(); new LoadData(TimeXYZDataPackage.DataType.RAW_DATA, MainMenuActivity.this, fileName).execute((Void[]) null); break; case 2: if (isDrawerOpen) drawerLayout.closeDrawers(); tracker = AnalyticsTrackers.getInstance().get(AnalyticsTrackers.Target.APP); tracker.send(new HitBuilders.EventBuilder().setCategory("Data Function") .setAction("Share Data").build()); i = new Intent(Intent.ACTION_SEND); i.setType("text/xml"); i.putExtra(Intent.EXTRA_SUBJECT, "Sending " + fileName + "as attachment"); i.putExtra(Intent.EXTRA_TEXT, fileName + "is attached."); File f = new File(FileUtilities.path + fileName + ".csv"); i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f)); startActivity(Intent.createChooser(i, "Choose an application...")); break; case 3: final AlertDialog.Builder confirmDelete = new AlertDialog.Builder( MainMenuActivity.this); confirmDelete .setMessage("Are you sure you want to delete " + fileName + "?"); confirmDelete.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { File f = new File(FileUtilities.path + fileName + ".csv"); Log.d("DELETION_SUCESS", String.valueOf(f.delete())); setUpListView(); } }); confirmDelete.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); confirmDelete.setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { dialog.dismiss(); } }); confirmDelete.show(); break; } } }); optionsMenu.show(); return true; } }); } }
From source file:com.androidinspain.deskclock.stopwatch.StopwatchFragment.java
/** * Send stopwatch time and lap times to an external sharing application. *//* ww w. ja v a2s . c o m*/ private void doShare() { // Disable the fab buttons to avoid double-taps on the share button. updateFab(BUTTONS_DISABLE); final String[] subjects = getResources().getStringArray(R.array.sw_share_strings); final String subject = subjects[(int) (Math.random() * subjects.length)]; final String text = mLapsAdapter.getShareText(); @SuppressLint("InlinedApi") @SuppressWarnings("deprecation") final Intent shareIntent = new Intent(Intent.ACTION_SEND) .addFlags(Utils.isLOrLater() ? Intent.FLAG_ACTIVITY_NEW_DOCUMENT : Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) .putExtra(Intent.EXTRA_SUBJECT, subject).putExtra(Intent.EXTRA_TEXT, text).setType("text/plain"); final Context context = getActivity(); final String title = context.getString(R.string.sw_share_button); final Intent shareChooserIntent = Intent.createChooser(shareIntent, title); try { context.startActivity(shareChooserIntent); } catch (ActivityNotFoundException anfe) { LogUtils.e("Cannot share lap data because no suitable receiving Activity exists"); updateFab(BUTTONS_IMMEDIATE); } }
From source file:dk.dr.radio.data.DRData.java
public void kundividi(Activity akt) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Esperanto-radio por Androjd"); sendIntent.putExtra(Intent.EXTRA_TEXT, "Saluton!\n\n" + "Mi rekomendas ke vi elprovas tiun i programon per via Androjda telefono:\n" + "La Esperanto-radio de Muzaiko\n" + "https://market.android.com/details?id=dk.nordfalk.esperanto.radio\n" + "\n" + "Muzaiko estas Esperanto-radio kiu konstante elsendas.\n" + "Eblas anka askulti la lastatempajn elsendojn de deko da aliaj radistacioj." // +"\n\n(kaj... ne forgesu meti 5 stelojn :-)" );// w w w . j ava 2s . c om sendIntent.setType("text/plain"); akt.startActivity(Intent.createChooser(sendIntent, "Sendi al")); }
From source file:com.cleanwiz.applock.ui.activity.LockMainActivity.java
public void shareMsg(String activityTitle, String msgTitle, String msgText, String imgPath) { Intent intent = new Intent(Intent.ACTION_SEND); if (imgPath == null || imgPath.equals("")) { intent.setType("text/plain"); } else {//from w w w . j a v a2 s . c o m File f = new File(imgPath); if (f.exists() && f.isFile()) { intent.setType("image/jpg"); Uri uri = Uri.fromFile(f); intent.putExtra(Intent.EXTRA_STREAM, uri); } } intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle); intent.putExtra(Intent.EXTRA_TEXT, msgText); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(Intent.createChooser(intent, activityTitle)); }
From source file:net.eledge.android.europeana.gui.activity.RecordActivity.java
private Intent createShareIntent() { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, recordController.getPortalUrl()); shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Check out this item on Europeana.eu!"); return shareIntent; }
From source file:com.google.zxing.client.android.result.ResultHandler.java
final void sendEmailFromUri(String uri, String email, String subject, String body) { Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse(uri)); if (email != null) { intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); }/*from w w w . j a v a 2s . c o m*/ putExtra(intent, Intent.EXTRA_SUBJECT, subject); putExtra(intent, Intent.EXTRA_TEXT, body); intent.setType("text/plain"); launchIntent(intent); }