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:codepath.watsiapp.fragments.DonateShareFragment.java
private void startShareIntent() { Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT, patientProfileUrl); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Fund Treatment"); startActivity(Intent.createChooser(shareIntent, "Share Story")); }
From source file:com.bordengrammar.bordengrammarapp.ParentsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View root = inflater.inflate(R.layout.fragment_parents, container, false); mail = (LinearLayout) root.findViewById(R.id.linmail); call = (LinearLayout) root.findViewById(R.id.lincall); call.setOnClickListener(new View.OnClickListener() { @Override//from ww w. ja v a 2 s. c om public void onClick(View arg0) { Intent cally = new Intent(Intent.ACTION_CALL); cally.setData(Uri.parse("tel:01795424192")); startActivity(cally); } }); mail.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle("Send a email to Borden Grammar"); alert.setMessage("Message: "); final EditText input = new EditText(getActivity()); alert.setView(input); alert.setPositiveButton("Send", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); // Do something with value! Intent email = new Intent(Intent.ACTION_SEND); email.setType("plain/text"); email.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "school@bordengrammar.kent.sch.uk" }); email.putExtra(Intent.EXTRA_SUBJECT, "Email (Sent From BGS APP) "); email.putExtra(Intent.EXTRA_TEXT, value); startActivity(Intent.createChooser(email, "Choose an Email client :")); } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alert.show(); } }); URL url = null; try { url = new URL( "http://website.bordengrammar.kent.sch.uk/index.php?option=com_rubberdoc&view=category&id=63%3Aletters&Itemid=241&format=feed&type=rss"); } catch (MalformedURLException e) { e.printStackTrace(); } Feed feed = null; try { feed = FeedParser.parse(url); } catch (FeedIOException e) { e.printStackTrace(); } catch (FeedXMLParseException e) { e.printStackTrace(); } catch (UnsupportedFeedException e) { e.printStackTrace(); } Boolean nully = false; for (int i = 0; i < 3; i++) { try { FeedItem item = feed.getItem(i); } catch (NullPointerException e) { e.printStackTrace(); nully = true; Toast.makeText(getActivity().getApplicationContext(), "Some features of this app require a internet connection", Toast.LENGTH_LONG).show(); } } if (!nully) { final FeedItem post1 = feed.getItem(1); final FeedItem post2 = feed.getItem(2); final FeedItem post3 = feed.getItem(3); TextView title1 = (TextView) root.findViewById(R.id.title1); TextView title2 = (TextView) root.findViewById(R.id.title2); TextView title3 = (TextView) root.findViewById(R.id.title3); title1.setText(post1.getTitle()); title2.setText(post2.getTitle()); title3.setText(post3.getTitle()); TextView link1 = (TextView) root.findViewById(R.id.link1); TextView link2 = (TextView) root.findViewById(R.id.link2); TextView link3 = (TextView) root.findViewById(R.id.link3); link1.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url1 = post1.getLink().toString(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url1), "text/html"); startActivity(intent); } }); link2.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url1 = post2.getLink().toString(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url1), "text/html"); startActivity(intent); } }); link3.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String url1 = post3.getLink().toString(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.parse(url1), "text/html"); startActivity(intent); } }); } else { TextView title1 = (TextView) root.findViewById(R.id.title1); TextView title2 = (TextView) root.findViewById(R.id.title2); TextView title3 = (TextView) root.findViewById(R.id.title3); title1.setText("No connection"); title2.setText("No connection"); title3.setText("No connection"); } TextView reader = (TextView) root.findViewById(R.id.reader); reader.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String appPackageName = "com.adobe.reader"; // getPackageName() from Context or Activity object try { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName))); } catch (android.content.ActivityNotFoundException anfe) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName))); } } }); return root; }
From source file:com.ideateam.plugin.Emailer.java
private void SendEmail(String email, String subject, String text, String attachFile) { String attachPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/UAR2015/" + attachFile; File file = new File(attachPath); Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email }); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file)); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(text)); this.cordova.getActivity().startActivity(Intent.createChooser(intent, "Send email...")); }
From source file:com.chess.genesis.activity.GameListFrag.java
protected void sendGame(final Bundle gamedata) { try {//from www .ja va2 s . c om final String gamename = gamedata.containsKey("gameid") ? gamedata.getString("white") + " V. " + gamedata.getString("black") : gamedata.getString("name"); final String filename = gamename + ".txt"; final String gamestr = GameParser.export(gamedata).toString(); final Uri uri = FileUtils.writeFile(filename, gamestr); final Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_STREAM, uri); intent.setType("application/json"); startActivity(intent); } catch (final JSONException e) { Toast.makeText(act, "Corrupt Game Data", Toast.LENGTH_LONG).show(); } catch (final FileNotFoundException e) { Toast.makeText(act, "File Not Found", Toast.LENGTH_LONG).show(); } catch (final IOException e) { Toast.makeText(act, "Error Reading File", Toast.LENGTH_LONG).show(); } }
From source file:cn.jarlen.media.sample.VideoActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_player); mSettings = new Settings(this); // handle arguments mVideoPath = getIntent().getStringExtra("videoPath"); Intent intent = getIntent();/*from w w w . j a v a 2s . co m*/ String intentAction = intent.getAction(); if (!TextUtils.isEmpty(intentAction)) { if (intentAction.equals(Intent.ACTION_VIEW)) { mVideoPath = intent.getDataString(); } else if (intentAction.equals(Intent.ACTION_SEND)) { mVideoUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) { String scheme = mVideoUri.getScheme(); if (TextUtils.isEmpty(scheme)) { Log.e(TAG, "Null unknown scheme\n"); finish(); return; } if (scheme.equals(ContentResolver.SCHEME_ANDROID_RESOURCE)) { mVideoPath = mVideoUri.getPath(); } else if (scheme.equals(ContentResolver.SCHEME_CONTENT)) { Log.e(TAG, "Can not resolve content below Android-ICS\n"); finish(); return; } else { Log.e(TAG, "Unknown scheme " + scheme + "\n"); finish(); return; } } } } if (!TextUtils.isEmpty(mVideoPath)) { new RecentMediaStorage(this).saveUrlAsync(mVideoPath); } // init UI Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); ActionBar actionBar = getSupportActionBar(); mMediaController = new AndroidMediaController(this, false); mMediaController.setSupportActionBar(actionBar); mToastTextView = (TextView) findViewById(R.id.toast_text_view); mHudView = (TableLayout) findViewById(R.id.hud_view); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mRightDrawer = (ViewGroup) findViewById(R.id.right_drawer); mDrawerLayout.setScrimColor(Color.TRANSPARENT); // init player IjkMediaPlayer.loadLibrariesOnce(null); IjkMediaPlayer.native_profileBegin("libijkplayer.so"); mVideoView = (IjkVideoView) findViewById(R.id.video_view); mVideoView.setMediaController(mMediaController); mVideoView.setHudView(mHudView); // prefer mVideoPath if (mVideoPath != null) mVideoView.setVideoPath(mVideoPath); else if (mVideoUri != null) mVideoView.setVideoURI(mVideoUri); else { Log.e(TAG, "Null Data Source\n"); finish(); return; } mVideoView.start(); }
From source file:id.zelory.tanipedia.activity.BacaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_baca); tmp = getIntent().getParcelableExtra("berita"); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);// w ww .j av a 2s. com getSupportActionBar().setDisplayHomeAsUpEnabled(true); CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle("TaniPedia"); animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow); gambar = (ImageView) findViewById(R.id.gambar); judul = (TextView) findViewById(R.id.judul); tanggal = (TextView) findViewById(R.id.tanggal); isi = (DocumentView) findViewById(R.id.isi); root = (LinearLayout) findViewById(R.id.ll_root_berita); fabButton = (FabButton) findViewById(R.id.determinate); fabButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, berita.getJudul()); intent.putExtra(Intent.EXTRA_TEXT, berita.getJudul() + "\n" + berita.getAlamat()); startActivity(Intent.createChooser(intent, "Bagikan")); } }); generateBeritaLainnya(); new DownloadData().execute(); }
From source file:com.vladstirbu.cordova.CDVInstagramPlugin.java
private void share(String imageString) { if (imageString != null && imageString.length() > 0) { byte[] imageData = Base64.decode(imageString, 0); FileOutputStream os = null; File filePath = new File(this.webView.getContext().getExternalFilesDir(null), "instagram.png"); try {// w ww . j a v a2 s . c o m os = new FileOutputStream(filePath, true); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { os.write(imageData); os.flush(); os.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("image/*"); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + filePath)); shareIntent.setPackage("com.instagram.android"); this.cordova.startActivityForResult((CordovaPlugin) this, shareIntent, 12345); } else { this.cbContext.error("Expected one non-empty string argument."); } }
From source file:ca.rmen.android.networkmonitor.app.about.AboutActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: NavUtils.navigateUpFromSameTask(this); return true; case R.id.action_send_logs: new AsyncTask<Void, Void, Boolean>() { @Override//w ww .j a v a 2s .c om protected Boolean doInBackground(Void... params) { if (!Log.prepareLogFile()) { return false; } // Bring up the chooser to share the file. Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); //sendIntent.setData(Uri.fromParts("mailto", getString(R.string.send_logs_to), null)); sendIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.support_send_debug_logs_subject)); String messageBody = getString(R.string.support_send_debug_logs_body); File f = new File(getExternalFilesDir(null), Log.FILE); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + f.getAbsolutePath())); sendIntent.setType("message/rfc822"); sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody); sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.support_send_debug_logs_to) }); startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.action_share))); return true; } @Override protected void onPostExecute(Boolean result) { if (!result) Toast.makeText(AboutActivity.this, R.string.support_error, Toast.LENGTH_LONG).show(); } }.execute(); return true; } return super.onOptionsItemSelected(item); }
From source file:at.wada811.utils.IntentUtils.java
/** * ??Intent??/*from ww w .j av a 2 s.c om*/ * * @param mailto * @param cc * @param bcc * @param subject * @param body */ public static Intent createSendMailIntent(String[] mailto, String[] cc, String[] bcc, String subject, String body) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType(HTTP.PLAIN_TEXT_TYPE); intent.putExtra(Intent.EXTRA_EMAIL, mailto); intent.putExtra(Intent.EXTRA_CC, cc); intent.putExtra(Intent.EXTRA_BCC, bcc); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, body); return intent; }
From source file:ch.berta.fabio.popularmovies.presentation.ui.fragments.MovieDetailsBaseFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true);/*from www.jav a2 s.c o m*/ mUseTwoPane = getResources().getBoolean(R.bool.use_two_pane_layout); mMovieRepo = new MovieRepositoryImpl(); mShareYoutubeIntent = new Intent(Intent.ACTION_SEND); mShareYoutubeIntent.setType("text/plain"); }