Example usage for android.content Intent ACTION_SEND

List of usage examples for android.content Intent ACTION_SEND

Introduction

In this page you can find the example usage for android.content Intent ACTION_SEND.

Prototype

String ACTION_SEND

To view the source code for android.content Intent ACTION_SEND.

Click Source Link

Document

Activity Action: Deliver some data to someone else.

Usage

From source file:at.tomtasche.reader.ui.activity.MainActivity.java

public void share(Uri uri) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setData(uri);/*  w w  w.  j  a  v a2 s.co  m*/
    intent.setType("application/*");
    intent.putExtra(Intent.EXTRA_STREAM, uri);

    try {
        startActivity(intent);
    } catch (Exception e) {
        e.printStackTrace();

        showCrouton(R.string.crouton_error_open_app, null, AppMsg.STYLE_ALERT);
    }
}

From source file:codepath.watsiapp.utils.Util.java

private static void startShareIntentWithExplicitSocialActivity(Activity ctx, ShareableItem patient,
        Set<String> socialActivitiesName, String displayName) {
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, patient.getShareableUrl());

    try {//from w w w.  j a  v a  2  s  .  co  m
        final PackageManager pm = ctx.getPackageManager();
        final List activityList = pm.queryIntentActivities(shareIntent, 0);
        int len = activityList.size();
        for (int i = 0; i < len; i++) {
            final ResolveInfo app = (ResolveInfo) activityList.get(i);
            Log.d("#####################", app.activityInfo.name);
            if (socialActivitiesName.contains(app.activityInfo.name)) {
                final ActivityInfo activity = app.activityInfo;
                final ComponentName name = new ComponentName(activity.applicationInfo.packageName,
                        activity.name);
                shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
                shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Fund Treatment");
                shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                shareIntent.setComponent(name);
                ctx.startActivity(shareIntent);
                break;
            }
        }
    } catch (final ActivityNotFoundException e) {
        Toast.makeText(ctx, "Could not find " + displayName + " app", Toast.LENGTH_SHORT).show();
    }

}

From source file:ca.rmen.android.poetassistant.main.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG && ActivityManager.isUserAMonkey()) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }/*from   w  w w  .  j  av a2 s .com*/
    super.onCreate(savedInstanceState);
    Log.d(TAG, "onCreate() called with: " + "savedInstanceState = [" + savedInstanceState + "]");
    mBinding = DataBindingUtil.setContentView(this, R.layout.activity_main);
    setSupportActionBar(mBinding.toolbar);
    Intent intent = getIntent();
    Uri data = intent.getData();
    mPagerAdapter = new PagerAdapter(this, getSupportFragmentManager(), intent);
    mPagerAdapter.registerDataSetObserver(mAdapterChangeListener);

    // Set up the ViewPager with the sections adapter.
    mBinding.viewPager.setAdapter(mPagerAdapter);
    mBinding.viewPager.setOffscreenPageLimit(5);
    mBinding.viewPager.addOnPageChangeListener(mOnPageChangeListener);

    mBinding.tabs.setupWithViewPager(mBinding.viewPager);
    AppBarLayoutHelper.enableAutoHide(mBinding);
    mAdapterChangeListener.onChanged();

    // If the app was launched with a query for the a particular tab, focus on that tab.
    if (data != null && data.getHost() != null) {
        Tab tab = Tab.parse(data.getHost());
        if (tab == null)
            tab = Tab.DICTIONARY;
        mBinding.viewPager.setCurrentItem(mPagerAdapter.getPositionForTab(tab));
    } else if (Intent.ACTION_SEND.equals(intent.getAction())) {
        mBinding.viewPager.setCurrentItem(mPagerAdapter.getPositionForTab(Tab.READER));
    }

    mSearch = new Search(this, mBinding.viewPager);
    loadDictionaries();
    setVolumeControlStream(AudioManager.STREAM_MUSIC);
}

From source file:de.golov.zeitgeistreich.ZeitGeistReichActivity.java

/** Called when the activity is first created. */
@Override//  ww w  .  jav a  2s.  c o  m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final ImageView imagePreview = (ImageView) findViewById(R.id.ImagePreview);
    Intent intent = getIntent();
    Bundle extras = intent.getExtras();
    Uri mImageUri = null;
    if (Intent.ACTION_SEND.equals(intent.getAction()) && extras != null) {
        if (extras.containsKey(Intent.EXTRA_STREAM)) {
            mImageUri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
            if (mImageUri != null) {
                int origId = Integer.parseInt(mImageUri.getLastPathSegment());
                Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(getContentResolver(), origId,
                        MediaStore.Images.Thumbnails.MINI_KIND, (BitmapFactory.Options) null);
                imagePreview.setImageBitmap(bitmap);
            }
        }
    }

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line,
            tag_suggests);
    final MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.TagEditView);
    textView.setAdapter(adapter);
    textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

    final Button button = (Button) findViewById(R.id.ZeitgeistSubmit);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            submitImage(textView.getText().toString());
        }
    });
}

From source file:com.ckchan.assignment1.ckchan_todolist.MainActivity.java

@Override
//Selecting action bar items
public boolean onOptionsItemSelected(MenuItem item) {

    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        Settings();// ww  w. j av  a  2  s. co  m
        return true;
    }

    //Handle presses on the action bar items
    switch (item.getItemId()) {

    case R.id.summary_info:

        SummaryInfo();
        return true;

    case R.id.email_all:

        try {

            Context context = getApplicationContext();
            TaskDatabase taskDatabase = new TaskDatabase();
            ;
            Email email = taskDatabase.loadEmailAddress(context);

            ArrayList<TodoTask> taskArray = (ArrayList<TodoTask>) taskDatabase.loadTaskData(context);
            ArrayList<TodoTask> archiveArray = (ArrayList<TodoTask>) taskDatabase.loadArchiveData(context);

            //StringBuilder code from:
            //http://stackoverflow.com/questions/12899953/in-java-how-to-append-a-string-more-efficiently
            StringBuilder stringBuilder = new StringBuilder();

            if (email != null) {

                Intent i = new Intent(Intent.ACTION_SEND);
                i.setType("message/rfc822");
                i.putExtra(Intent.EXTRA_EMAIL, new String[] { email.getAddress() });
                i.putExtra(Intent.EXTRA_SUBJECT, "Todo and Archive Tasks");

                stringBuilder.append("Todo Tasks\n");

                for (TodoTask task : taskArray) {

                    stringBuilder.append(task.getTaskDescription() + "\n");
                }
                stringBuilder.append("Archive Tasks\n");

                for (TodoTask task : archiveArray) {

                    stringBuilder.append(task.getTaskDescription() + "\n");
                }
                String emailContent = stringBuilder.toString();
                i.putExtra(Intent.EXTRA_TEXT, emailContent);

                try {

                    startActivity(Intent.createChooser(i, "Send mail..."));
                } catch (android.content.ActivityNotFoundException ex) {

                    Toast.makeText(context, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
                }
            }

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.pixellostudio.qqdroid.BaseQuote.java

public boolean onContextItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case 1:// ww w.ja v  a2  s. c o  m
        AdapterView.AdapterContextMenuInfo menuInfo = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();

        Spanned quote = Html.fromHtml((String) view.getAdapter().getItem(menuInfo.position));

        Intent i = new Intent(Intent.ACTION_SEND);
        i.putExtra(Intent.EXTRA_TEXT,
                getBaseContext().getText(R.string.quotefrom) + " " + name + " : " + quote);
        i.setType("text/plain");
        startActivity(Intent.createChooser(i, this.getText(R.string.share)));

        break;
    default:
        return super.onContextItemSelected(item);
    }
    return true;
}

From source file:info.semanticsoftware.semassist.android.activity.SemanticAssistantsActivity.java

/** Sets the user interface and retrieves the list of
 * available services./*w  w w.j a  va  2s  .  co  m*/
 * @param savedInstanceState saved instance state
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Find the user preferred Semantic Assistants server
    serverURL = readServerSettings();

    // Retrieve the list of available assistants
    getServicesTask task = new getServicesTask();
    Log.i(TAG, "Retrieving available assistants from " + serverURL);
    task.execute(serverURL);

    // while the task is being executed, create the user interface
    setContentView(R.layout.main);
    lblAvAssist = (TextView) findViewById(R.id.lblAvAssist);
    txtInput = (EditText) findViewById(R.id.txtInput);

    // catch the text sent from another app on the system
    if (Intent.ACTION_SEND.equals(getIntent().getAction())) {
        Bundle bundle = getIntent().getExtras();
        txtInput.setText(bundle.getString(Intent.EXTRA_TEXT));
        getIntent().setAction(null);
    }

    btnClear = (Button) findViewById(R.id.btnClear);
    btnClear.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            txtInput.setText("");
        }
    });
}

From source file:com.fsa.en.dron.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    RateThisApp.Config config = new RateThisApp.Config(5, 10);
    config.setTitle(R.string.my_own_title);
    config.setMessage(R.string.my_own_message);
    config.setYesButtonText(R.string.my_own_rate);
    config.setNoButtonText(R.string.my_own_thanks);
    config.setCancelButtonText(R.string.my_own_cancel);
    RateThisApp.init(config);//from   ww  w  . ja va 2 s . c om
    RateThisApp.setCallback(new RateThisApp.Callback() {
        @Override
        public void onYesClicked() {
            final String appPackageName = getPackageName(); // 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)));
            }
        }

        @Override
        public void onNoClicked() {
            TastyToast.makeText(getApplicationContext(), "Vuelve pronto!", TastyToast.LENGTH_LONG,
                    TastyToast.INFO);
        }

        @Override
        public void onCancelClicked() {
            TastyToast.makeText(getApplicationContext(), "Prometo tomar mejores fotografias!",
                    TastyToast.LENGTH_LONG, TastyToast.ERROR);
        }
    });
    button = (Button) findViewById(R.id.button);
    button.setVisibility(View.INVISIBLE);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkConnection();
        }
    });
    BottomNavigationBar bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
    bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE);
    bottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED);
    bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
    bottomNavigationBar.setBarBackgroundColor(R.color.material_light_blue_800);
    bottomNavigationBar.setActiveColor(R.color.material_grey_900);
    bottomNavigationBar.setInActiveColor(R.color.material_blue_grey_200);
    bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.compose, "Mensaje"))
            .addItem(new BottomNavigationItem(R.drawable.sociales, "Sociales"))
            .addItem(new BottomNavigationItem(R.drawable.share, "Cuntale a un amigo")).initialise();
    bottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
        @Override
        public void onTabSelected(int position) {
            switch (position) {
            case 0:
                Intent email = new Intent(Intent.ACTION_SEND);
                email.putExtra(Intent.EXTRA_EMAIL, new String[] { "marceloespinoza00@gmail.com" });
                email.putExtra(Intent.EXTRA_SUBJECT, "Formosa en dron");
                email.putExtra(Intent.EXTRA_TEXT, "Dej tu mensaje");
                email.setType("message/rfc822");
                startActivity(Intent.createChooser(email, "Elige un cliente :"));
                break;
            case 1:
                Intent intent = new Intent(getApplication(), FacebookActivity.class);
                startActivity(intent);
                break;
            case 2:

                Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
                sharingIntent.setType("text/plain");
                sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Formosa en dron");
                sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                        "https://play.google.com/store/apps/details?id=com.fsa.en.dron");
                startActivity(Intent.createChooser(sharingIntent, "Compartir via"));
                break;

            }

        }

        @Override
        public void onTabUnselected(int position) {

        }

        @Override
        public void onTabReselected(int position) {
            switch (position) {
            case 0:

                break;
            case 1:
                Intent intent = new Intent(getApplication(), FacebookActivity.class);
                startActivity(intent);
                break;
            case 2:

                break;

            }
        }
    });
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    LayoutInflater inflator = LayoutInflater.from(this);
    View v = inflator.inflate(R.layout.toolbar_title, null);
    Typeface budget = Typeface.createFromAsset(getAssets(), "fonts/Budget.otf");
    Typeface typographica = Typeface.createFromAsset(getAssets(), "fonts/TypoGraphica.otf");
    TextView mToolbarCustomTitle = (TextView) v.findViewById(R.id.title);
    TextView mToolbarCustomSubTitle = (TextView) v.findViewById(R.id.subtitle);
    mToolbarCustomTitle.setText("Formosa");
    mToolbarCustomSubTitle.setText("en dron");
    mToolbarCustomTitle.setTypeface(typographica);
    mToolbarCustomSubTitle.setTypeface(budget);
    getSupportActionBar().setCustomView(v);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            int id = item.getItemId();
            if (id == R.id.recargar) {
                checkConnection();
            }
            if (id == R.id.info) {
                showDialog();
            }
            return false;
        }
    });
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    recyclerView.addOnItemTouchListener(new GalleryAdapter.RecyclerTouchListener(getApplicationContext(),
            recyclerView, new GalleryAdapter.ClickListener() {
                @Override
                public void onClick(View view, int position) {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("images", images);
                    bundle.putInt("position", position);

                    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                    SlideshowDialogFragment newFragment = SlideshowDialogFragment.newInstance();
                    newFragment.setArguments(bundle);
                    newFragment.show(ft, "slideshow");
                }

                @Override
                public void onLongClick(View view, int position) {

                }
            }));
    pDialog = new ProgressDialog(this);
    images = new ArrayList<>();
    mAdapter = new GalleryAdapter(getApplicationContext(), images);
    RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getApplicationContext(), 2);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(mAdapter);

}

From source file:com.abiansoftware.lib.reader.AbianReaderItemActivity.java

@Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        Intent intent = new Intent(this, AbianReaderActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);/*from  w w  w . ja  va2  s  . co m*/

        return true;
    } else if (item.getItemId() == SHARE_ITEM_ID) {
        String shareMessage = getString(R.string.share_message);
        String shareTitle = getString(R.string.share_title);

        AbianReaderItem targetItem = AbianReaderApplication.getData().getItemNumber(m_currentPage);

        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra(Intent.EXTRA_SUBJECT, shareMessage);
        sharingIntent.putExtra(Intent.EXTRA_TEXT, targetItem.getLink());
        startActivity(Intent.createChooser(sharingIntent, shareTitle));

        return true;
    } else if (item.getItemId() == OPEN_BROWSER_ITEM_ID) {
        AbianReaderItem targetItem = AbianReaderApplication.getData().getItemNumber(m_currentPage);

        String url = targetItem.getLink();
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        startActivity(i);
    }

    return super.onOptionsItemSelected(item);
}