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.btmura.android.reddit.app.MenuHelper.java
public static void share(Context context, CharSequence subject, CharSequence text) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, subject); intent.putExtra(Intent.EXTRA_TEXT, text); Contexts.startActivity(context, makeChooser(context, intent, R.string.menu_share)); }
From source file:com.krayzk9s.imgurholo.activities.ImgurLinkActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); destroyed = false;/*from ww w . ja v a 2 s . co m*/ if (getActionBar() != null) getActionBar().setDisplayHomeAsUpEnabled(true); Intent intent = getIntent(); String action = intent.getAction(); String type = intent.getType(); Log.d("New Intent", intent.toString()); if (Intent.ACTION_SEND.equals(action) && type != null) { if (type.startsWith("image/")) { Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show(); Intent serviceIntent = new Intent(this, UploadService.class); if (intent.getExtras() == null) finish(); serviceIntent.setData((Uri) intent.getExtras().get("android.intent.extra.STREAM")); startService(serviceIntent); finish(); } } else if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { Log.d("sending", "sending multiple"); Toast.makeText(this, R.string.toast_uploading, Toast.LENGTH_SHORT).show(); ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM); Intent serviceIntent = new Intent(this, UploadService.class); serviceIntent.putParcelableArrayListExtra("images", list); startService(serviceIntent); finish(); } else if (Intent.ACTION_VIEW.equals(action) && intent.getData() != null && intent.getData().toString().startsWith("http://imgur.com/a")) { String uri = intent.getData().toString(); album = uri.split("/")[4]; Log.d("album", album); Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM); fetcher.execute(); } else if (Intent.ACTION_VIEW.equals(action) && intent.getData().toString().startsWith("http://imgur.com/gallery/")) { String uri = intent.getData().toString(); final String album = uri.split("/")[4]; if (album.length() == 5) { Log.d("album", album); Fetcher fetcher = new Fetcher(this, "/3/album/" + album, ApiCall.GET, null, apiCall, ALBUM); fetcher.execute(); } else if (album.length() == 7) { Log.d("image", album); Fetcher fetcher = new Fetcher(this, "/3/gallery/image/" + album, ApiCall.GET, null, apiCall, IMAGE); fetcher.execute(); } } else if (Intent.ACTION_VIEW.equals(action) && intent.getData().toString().startsWith("http://i.imgur")) { String uri = intent.getData().toString(); final String image = uri.split("/")[3].split("\\.")[0]; Log.d("image", image); Fetcher fetcher = new Fetcher(this, "/3/image/" + image, ApiCall.GET, null, apiCall, IMAGE); fetcher.execute(); } }
From source file:com.chale22.ico01.ThemeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mShareIntent = new Intent(); mShareIntent.setAction(Intent.ACTION_SEND); mShareIntent.setType("text/plain"); mShareIntent.putExtra(Intent.EXTRA_TEXT, "From me to you, this text is new."); tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); ViewPager pager = (ViewPager) findViewById(R.id.pager); adapter = new MyPagerAdapter(getSupportFragmentManager()); pager.setAdapter(adapter);/*ww w. j ava 2s.c om*/ final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); pager.setPageMargin(pageMargin); tabs.setViewPager(pager); }
From source file:com.manning.androidhacks.hack004.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.prefs); Preference sharePref = findPreference("pref_share"); Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Check this app!"); shareIntent.putExtra(Intent.EXTRA_TEXT, "Check this awesome app at: ..."); sharePref.setIntent(shareIntent);/*from ww w.java2s. co m*/ Preference ratePref = findPreference("pref_rate"); Uri uri = Uri.parse("market://details?id=" + getPackageName()); Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri); ratePref.setIntent(goToMarket); updateUserText(); }
From source file:ca.ualberta.slevinsk.gameshow.StatsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_stats); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from w w w . j a va 2 s.co m*/ ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager); viewPager.setAdapter(new StatsFragmentPagerAdapter(getSupportFragmentManager(), StatsActivity.this)); TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs); tabLayout.setupWithViewPager(viewPager); getSupportActionBar().setDisplayHomeAsUpEnabled(true); ReactionTimersManager.initManager(getApplicationContext()); BuzzerCounterManager.initManager(getApplicationContext()); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/rfc822"); intent.putExtra(Intent.EXTRA_SUBJECT, "slevinsk - stats"); intent.putExtra(Intent.EXTRA_TEXT, BuzzerCounterController.generateEmailData() + ReactionTimersController.generateEmailData()); try { startActivity(intent); } catch (ActivityNotFoundException e) { Snackbar.make(view, "There is no email client installed", Snackbar.LENGTH_LONG).show(); } } }); }
From source file:com.chale22.ico01.IconActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_icon); mShareIntent = new Intent(); mShareIntent.setAction(Intent.ACTION_SEND); mShareIntent.setType("text/plain"); mShareIntent.putExtra(Intent.EXTRA_TEXT, "From me to you, this text is new."); tabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); ViewPager pager = (ViewPager) findViewById(R.id.pager); adapter = new IconPagerAdapter(getSupportFragmentManager()); pager.setAdapter(adapter);/*from w ww .jav a 2 s . c o m*/ final int pageMargin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, getResources().getDisplayMetrics()); pager.setPageMargin(pageMargin); tabs.setViewPager(pager); }
From source file:com.btmura.android.reddit.app.MenuHelper.java
public static void shareImageUrl(Context context, String url) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(url)); Contexts.startActivity(context, intent); }
From source file:de.jamoo.muzei.WallSource.java
@Override public void onCustomCommand(int id) { super.onCustomCommand(id); if (id == COMMAND_ID_SHARE) { Artwork currentArtwork = getCurrentArtwork(); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); Uri artUrl = currentArtwork.getImageUri(); if (DEBUG) Log.d(TAG, "artUrl: " + artUrl); String author = currentArtwork.getByline(); if (DEBUG) Log.d(TAG, "author: " + author); String playUrl = "http://play.google.com/store/apps/details?id=" + getPackageName(); if (DEBUG) Log.d(TAG, "playUrl: " + playUrl); shareIntent.putExtra(Intent.EXTRA_TEXT, "My wallpaper today is " + currentArtwork.getTitle() + " by " + author + " \n" + artUrl + " \n" + "from the " + getString(R.string.app_name) + " app\n" + "Get it now on the PlayStore! " + playUrl); shareIntent = Intent.createChooser(shareIntent, "Share Wallpaper"); shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(shareIntent);//from w w w. j a v a2 s . c o m } }
From source file:org.geek.utils.ApplicationUtils.java
/** * Share a page.//w w w . j a va2 s .co m * @param activity The parent activity. * @param title The page title. * @param url The page url. */ public static void sharePage(Activity activity, String title, String url) { Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, url); shareIntent.putExtra(Intent.EXTRA_SUBJECT, title); try { activity.startActivity( Intent.createChooser(shareIntent, activity.getString(R.string.Main_ShareChooserTitle))); } catch (android.content.ActivityNotFoundException ex) { // if no app handles it, do nothing } }
From source file:com.granita.contacticloudsync.ui.DebugInfoActivity.java
public void onShare(MenuItem item) { if (!TextUtils.isEmpty(report)) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setType("text/plain"); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Exception Details"); try {//from www .j a v a2 s .c o m File reportFile = File.createTempFile("debug", ".txt", getExternalCacheDir()); Constants.log.debug("Writing debug info to " + reportFile.getAbsolutePath()); FileWriter writer = new FileWriter(reportFile); writer.write(report); writer.close(); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(reportFile)); } catch (IOException e) { // let's hope the report is < 1 MB sendIntent.putExtra(Intent.EXTRA_TEXT, report); } startActivity(sendIntent); } }