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:org.mrquiz.android.tinyurl.SendTinyUrlActivity.java

private void send() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");

    Intent originalIntent = getIntent();
    if (Intent.ACTION_SEND.equals(originalIntent.getAction())) {
        // Copy extras from the original intent because they miht contain
        // additional information about the URL (e.g., the title of a
        // YouTube video). Do this before setting Intent.EXTRA_TEXT to avoid
        // overwriting the TinyShare.
        intent.putExtras(originalIntent.getExtras());
    }//from w  w w .  j  ava 2  s.co  m

    intent.putExtra(Intent.EXTRA_TEXT, mTinyUrl);
    try {
        CharSequence template = getText(R.string.title_send);
        String title = String.format(String.valueOf(template), mTinyUrl);
        startActivity(Intent.createChooser(intent, title));
    } catch (ActivityNotFoundException e) {
        handleError(e);
    }
}

From source file:com.vrem.wifianalyzer.navigation.items.ExportItem.java

Intent createSendIntent() {
    return new Intent(Intent.ACTION_SEND);
}

From source file:net.reichholf.dreamdroid.activities.DreamDroidShareActivity.java

@SuppressWarnings("deprecation")
private void playOnDream(Profile p) {
    String url = null;//from w  ww. j av a2  s. c  o  m
    Intent i = getIntent();
    Bundle extras = i.getExtras();
    mShc = SimpleHttpClient.getInstance(p);
    if (Intent.ACTION_SEND.equals(i.getAction()))
        url = extras.getString(Intent.EXTRA_TEXT);
    else if (Intent.ACTION_VIEW.equals(i.getAction()))
        url = i.getDataString();

    if (url != null) {
        Log.i(LOG_TAG, url);
        Log.i(LOG_TAG, p.getHost());

        String time = DateFormat.getDateFormat(this).format(new Date());
        String title = getString(R.string.sent_from_dreamdroid, time);
        if (extras != null) {
            // semperVidLinks sends "artist" and "song" attributes for the
            // youtube video titles
            String song = extras.getString("song");
            if (song != null) {
                String artist = extras.getString("artist");
                if (artist != null)
                    title = artist + " - " + song;
            } else {
                String tmp = extras.getString("title");
                if (tmp != null)
                    title = tmp;
            }
        }
        mTitle = new String(title);

        url = URLEncoder.encode(url).replace("+", "%20");
        title = URLEncoder.encode(title).replace("+", "%20");

        String ref = "4097:0:1:0:0:0:0:0:0:0:" + url + ":" + title;
        Log.i(LOG_TAG, ref);
        ArrayList<NameValuePair> params = new ArrayList<NameValuePair>();
        params.add(new BasicNameValuePair("file", ref));
        execSimpleResultTask(params);
    } else {
        finish();
    }
}

From source file:com.banana.instagrab.helper.NotificationUtils.java

private static PendingIntent contentIntent(Context context) {

    //        String path = "abc"; //folder name
    //        String fileName = "1234.jpg";
    //        String directoryPath = Environment.getExternalStorageDirectory() + File.separator + Environment.DIRECTORY_DCIM;
    //        File dirFile = new File(directoryPath + File.separator + path);
    //        if (!dirFile.exists()) {
    //            Log.d("JSONTEST", "dirFile.mkdir() result : " + dirFile.mkdir());
    //        }//from   w ww.  ja v  a  2s .  c o m
    //        File toBeSavedFile = new File(dirFile.getPath() + File.separator + fileName);
    //        Intent intent = new Intent();
    //        intent.setAction(Intent.ACTION_VIEW);
    //        intent.setDataAndType(Uri.parse(toBeSavedFile.toString()), "image/*");

    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, "Awesome message");
    sendIntent.setType("text/plain");

    return PendingIntent.getService(context, WATER_REMINDER_PENDING_INTENT_ID, sendIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    //        return PendingIntent.getActivity(
    //                context,
    //                WATER_REMINDER_PENDING_INTENT_ID,
    //                intent,
    //                PendingIntent.FLAG_UPDATE_CURRENT);
}

From source file:net.reichholf.dreamdroid.activities.ShareActivity.java

@SuppressWarnings("deprecation")
private void playOnDream(Profile p) {
    String url = null;//  ww w. j  a  v  a 2 s  .  c om
    Intent i = getIntent();
    Bundle extras = i.getExtras();
    mShc = SimpleHttpClient.getInstance(p);
    if (Intent.ACTION_SEND.equals(i.getAction()))
        url = extras.getString(Intent.EXTRA_TEXT);
    else if (Intent.ACTION_VIEW.equals(i.getAction()))
        url = i.getDataString();

    if (url != null) {
        Log.i(LOG_TAG, url);
        Log.i(LOG_TAG, p.getHost());

        String time = DateFormat.getDateFormat(this).format(new Date());
        String title = getString(R.string.sent_from_dreamdroid, time);
        if (extras != null) {
            // semperVidLinks sends "artist" and "song" attributes for the
            // youtube video titles
            String song = extras.getString("song");
            if (song != null) {
                String artist = extras.getString("artist");
                if (artist != null)
                    title = artist + " - " + song;
            } else {
                String tmp = extras.getString("title");
                if (tmp != null)
                    title = tmp;
            }
        }
        mTitle = title;

        url = URLEncoder.encode(url).replace("+", "%20");
        title = URLEncoder.encode(title).replace("+", "%20");

        String ref = "4097:0:1:0:0:0:0:0:0:0:" + url + ":" + title;
        Log.i(LOG_TAG, ref);
        ArrayList<NameValuePair> params = new ArrayList<>();
        params.add(new BasicNameValuePair("file", ref));
        execSimpleResultTask(params);
    } else {
        finish();
    }
}

From source file:com.samuelcastro.cordova.InstagramSharePlugin.java

private void shareImage(String imageString, String captionString) {
    if (imageString != null && imageString.length() > 0) {
        byte[] imageData = Base64.decode(imageString, 0);

        File file = null;/*from  w w  w. j a  va  2  s  .c om*/
        FileOutputStream os = null;

        File parentDir = this.webView.getContext().getExternalFilesDir(null);
        File[] oldImages = parentDir.listFiles(OLD_IMAGE_FILTER);
        for (File oldImage : oldImages) {
            oldImage.delete();
        }

        try {
            file = File.createTempFile("instagram", ".png", parentDir);
            os = new FileOutputStream(file, true);
        } catch (Exception e) {
            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://" + file));
        shareIntent.putExtra(Intent.EXTRA_TEXT, captionString);
        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:com.android.messaging.ui.photoviewer.BuglePhotoViewController.java

private void updateShareActionProvider() {
    final PhotoPagerAdapter adapter = getAdapter();
    final Cursor cursor = getCursorAtProperPosition();
    if (mShareActionProvider == null || mShareItem == null || adapter == null || cursor == null) {
        // Not enough stuff loaded to update the share action
        return;//from  w  ww  . jav  a2 s.  c om
    }
    final String photoUri = adapter.getPhotoUri(cursor);
    if (isTempFile()) {
        mShareItem.setVisible(false);
        return;
    }
    final String contentType = adapter.getContentType(cursor);

    final Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType(contentType);
    shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(photoUri));
    mShareActionProvider.setShareIntent(shareIntent);
    mShareItem.setVisible(true);
}

From source file:br.com.PartoHumanizado.fragment.EnviarPlanoDePartoFragment.java

@OnClick(R.id.enviar)
public void enviar() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    //        intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_EMAIL, "");
    intent.putExtra(Intent.EXTRA_SUBJECT, "Plano de Parto");
    intent.putExtra(Intent.EXTRA_TEXT, texto.getText().toString());

    startActivity(Intent.createChooser(intent, "Enviar email"));
    //        startActivity(intent);
}

From source file:ayushi.view.fragment.ContactUsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.frag_about, container, false);

    getActivity().setTitle("Contact Us");

    mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar);
    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar);
    }/*from   w  ww.  j ava  2  s  .  c  om*/

    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        mToolbar.setNavigationIcon(R.drawable.ic_drawer);

    }

    mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            ((ECartHomeActivity) getActivity()).getmDrawerLayout().openDrawer(GravityCompat.START);
        }
    });

    mToolbar.setTitleTextColor(Color.WHITE);

    rootView.findViewById(R.id.locations).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

        }
    });

    rootView.findViewById(R.id.contact_num).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            Intent callIntent = new Intent(Intent.ACTION_DIAL);
            callIntent.setData(Uri.parse("tel:" + "8888813275"));
            startActivity(callIntent);

        }
    });

    rootView.setFocusableInTouchMode(true);
    rootView.requestFocus();
    rootView.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {

            if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {

                Utils.switchContent(R.id.frag_container, Utils.HOME_FRAGMENT,
                        ((ECartHomeActivity) (getContext())), AnimationType.SLIDE_UP);

            }
            return true;
        }
    });

    rootView.findViewById(R.id.site_dev).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://hiteshsahu.com/"));
            startActivity(browserIntent);

        }
    });

    rootView.findViewById(R.id.email).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
            emailIntent.setType("text/plain");
            emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                    new String[] { "hiteshkumarsahu1990@gmail.com" });
            emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hello There");
            emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Add Message here");

            emailIntent.setType("message/rfc822");

            try {
                startActivity(Intent.createChooser(emailIntent, "Send email using..."));
            } catch (android.content.ActivityNotFoundException ex) {
                Toast.makeText(getActivity(), "No email clients installed.", Toast.LENGTH_SHORT).show();
            }

        }
    });

    return rootView;
}

From source file:edu.mit.mobile.android.livingpostcards.data.Card.java

/**
 * Creates an {@link Intent#ACTION_SEND} intent to share the given card.
 *
 * @param context//from  w w  w  . j  a va2  s .  c  o  m
 * @param webUrl
 *            the content of the card's {@link Card#COL_WEB_URL} field. Can be a relative URL.
 * @param title
 *            the title of the card
 * @return an intent, within a chooser, that can be used with
 *         {@link Context#startActivity(Intent)}
 */
public static Intent createShareIntent(Context context, String webUrl, CharSequence title) {
    final NetworkClient nc = LocastApplication.getNetworkClient(context,
            Authenticator.getFirstAccount(context));
    final Intent sendIntent = new Intent(Intent.ACTION_SEND);
    sendIntent.setType("text/plain");
    sendIntent.putExtra(Intent.EXTRA_TEXT,
            context.getString(R.string.send_intent_message, nc.getFullUrlAsString(webUrl)));
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.send_intent_subject, title));
    return Intent.createChooser(sendIntent, context.getString(R.string.send_intent_chooser_title));

}