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:com.z.stproperty.PropertyDetail.java

/**
 * User can share this property details with their friends through email as well
 * and can choose other options like whats-app, drop-box etc as well
 *//*from w w w  .  j a  v a 2 s .c om*/
private void shareWithEmail() {
    try {
        String path = Images.Media.insertImage(getContentResolver(), SharedFunction.loadBitmap(shareImageLink),
                "title", null);
        Uri screenshotUri = Uri.parse(path);
        String shareContent = title + "\n\n" + prurl + "\n\n" + price + "\n\n";
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("image/png");
        intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "" });
        intent.putExtra(Intent.EXTRA_SUBJECT, "Property to share with you");
        intent.putExtra(Intent.EXTRA_TEXT,
                "I think you might be interested in a property advertised on STProperty \n\n" + shareContent);
        intent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
        SharedFunction.postAnalytics(PropertyDetail.this, "Lead", "Email Share", title);
        startActivity(Intent.createChooser(intent, ""));
    } catch (Exception e) {
        Log.e(this.getClass().getSimpleName(), e.getLocalizedMessage(), e);
    }
}

From source file:mp.paschalis.EditBookActivity.java

/**
 * Creates a sharing {@link Intent}.//from  w  w w .j a  va 2  s . co m
 *
 * @return The sharing intent.
 */
private Intent createShareIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");

    String root = Environment.getExternalStorageDirectory() + ".SmartLib/Images";
    new File(root).mkdirs();

    File file = new File(root, app.selectedBook.isbn);

    try {
        FileOutputStream os = new FileOutputStream(file);
        bitmapBookCover.compress(CompressFormat.PNG, 80, os);
        os.flush();
        os.close();

        Uri uri = Uri.fromFile(file);
        shareIntent.putExtra(Intent.EXTRA_STREAM, uri);

    } catch (Exception e) {
        Log.e(TAG, e.getStackTrace().toString());
    }

    String bookInfo = "\n\n\n\nMy " + getString(R.string.bookInfo) + ":\n" + getString(R.string.title)
            + ": \t\t\t\t" + app.selectedBook.title + "\n" + getString(R.string.author) + ": \t\t\t"
            + app.selectedBook.authors + "\n" + getString(R.string.isbn) + ": \t\t\t\t" + app.selectedBook.isbn
            + "\n" + getString(R.string.published_) + " \t" + app.selectedBook.publishedYear + "\n"
            + getString(R.string.pages_) + " \t\t\t" + app.selectedBook.pageCount + "\n"
            + getString(R.string.isbn) + ": \t\t\t\t" + app.selectedBook.isbn + "\n"
            + getString(R.string.status) + ": \t\t\t"
            + App.getBookStatusString(app.selectedBook.status, EditBookActivity.this) + "\n\n"
            + "http://books.google.com/books?vid=isbn" + app.selectedBook.isbn;

    shareIntent.putExtra(Intent.EXTRA_TEXT, bookInfo);

    return shareIntent;
}

From source file:com.dwdesign.tweetings.fragment.ConversationFragment.java

public void linkGenerationComplete(String url) {
    if (isShare == false) {
        final Intent intent = new Intent(INTENT_ACTION_COMPOSE);
        final Bundle bundle = new Bundle();
        bundle.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
        bundle.putString(INTENT_KEY_TEXT, url);
        intent.putExtras(bundle);//from  w  ww.j av a  2s .c o  m
        startActivity(intent);
    } else {
        final Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_TEXT, url);
        startActivity(Intent.createChooser(intent, getString(R.string.share)));
    }
}

From source file:com.antew.redditinpictures.library.ui.ImageViewerActivity.java

/**
 * Handler for when the user selects an item from the ActionBar.
 * <p>/*from   w w  w  .j  a v  a2  s.  c  om*/
 * The default functionality implements:<br>
 * - Toggling the swipe lock on the ViewPager via toggleViewPagerLock()<br>
 * - Sharing the post via the Android ACTION_SEND intent, the URL shared is provided by
 * subclasses via {@link #getUrlForSharing()}<br>
 * - Viewing the post in a Web browser (the URL is provided by subclasses from
 * {@link #getPostUri()} <br>
 * - Displaying a dialog to get the filename to use when saving an image, subclasses will
 * implement {@link #onFinishSaveImageDialog(String)}
 * </p>
 */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        EasyTracker.getInstance(this)
                .send(MapBuilder.createEvent(Constants.Analytics.Category.ACTION_BAR_ACTION,
                        Constants.Analytics.Action.HOME, null, null).build());
        finish();
        return true;
    case R.id.lock_viewpager:
        if (mPager.isSwipingEnabled()) {
            EasyTracker.getInstance(this)
                    .send(MapBuilder.createEvent(Constants.Analytics.Category.ACTION_BAR_ACTION,
                            Constants.Analytics.Action.TOGGLE_SWIPING, Constants.Analytics.Label.DISABLED, null)
                            .build());
        } else {
            EasyTracker.getInstance(this)
                    .send(MapBuilder.createEvent(Constants.Analytics.Category.ACTION_BAR_ACTION,
                            Constants.Analytics.Action.TOGGLE_SWIPING, Constants.Analytics.Label.ENABLED, null)
                            .build());
        }

        // Lock or unlock swiping in the ViewPager
        setSwipingState(!mPager.isSwipingEnabled(), true);
        return true;
    case R.id.share_post:
        EasyTracker.getInstance(this)
                .send(MapBuilder.createEvent(Constants.Analytics.Category.ACTION_BAR_ACTION,
                        Constants.Analytics.Action.SHARE_POST, getSubreddit(), null).build());
        String subject = getString(R.string.check_out_this_image);
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT, subject);
        intent.putExtra(Intent.EXTRA_TEXT, subject + " " + getUrlForSharing());
        startActivity(Intent.createChooser(intent, getString(R.string.share_using_)));
        return true;
    case R.id.view_post:
        EasyTracker
                .getInstance(this).send(
                        MapBuilder
                                .createEvent(Constants.Analytics.Category.ACTION_BAR_ACTION,
                                        Constants.Analytics.Action.OPEN_POST_EXTERNAL, getSubreddit(), null)
                                .build());
        Intent browserIntent = new Intent(Intent.ACTION_VIEW, getPostUri());
        startActivity(browserIntent);
        return true;
    case R.id.save_post:
        EasyTracker.getInstance(this)
                .send(MapBuilder.createEvent(Constants.Analytics.Category.ACTION_BAR_ACTION,
                        Constants.Analytics.Action.SAVE_POST, getSubreddit(), null).build());
        handleSaveImage();
        return true;
    case R.id.report_image:
        EasyTracker.getInstance(this)
                .send(MapBuilder.createEvent(Constants.Analytics.Category.ACTION_BAR_ACTION,
                        Constants.Analytics.Action.REPORT_POST, getSubreddit(), null).build());
        new Thread(new Runnable() {
            @Override
            public void run() {
                reportCurrentItem();
            }
        }).start();
        Toast.makeText(this, R.string.image_display_issue_reported, Toast.LENGTH_LONG).show();
        return true;
    default:
        return false;
    }
}

From source file:com.google.android.apps.paco.FeedbackActivity.java

private void sendEmail(String body, String subject, String userEmail) {
    userEmail = findAccount(userEmail);/*from w  w  w . j  a v  a2  s . c  o  m*/
    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    String aEmailList[] = { userEmail };
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, aEmailList);
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, body);
    emailIntent.setType("plain/text");

    startActivity(emailIntent);
}

From source file:info.guardianproject.gpg.KeyListFragment.java

private void keyserverOperation(final int operation, final ActionMode mode) {
    new AsyncTask<Void, Void, Void>() {
        final Context context = getActivity().getApplicationContext();
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
        final String host = prefs.getString(GpgPreferenceActivity.PREF_KEYSERVER,
                "ipv4.pool.sks-keyservers.net");
        final long[] selected = mListView.getCheckedItemIds();
        final Intent intent = new Intent(context, ImportFileActivity.class);

        @Override//from   ww  w.  j  a  va 2  s  .com
        protected Void doInBackground(Void... params) {
            HkpKeyServer keyserver = new HkpKeyServer(host);
            if (operation == DELETE_KEYS) {
                String args = "--batch --yes --delete-keys";
                for (int i = 0; i < selected.length; i++) {
                    args += " " + Long.toHexString(selected[i]);
                }
                GnuPG.gpg2(args);
            } else if (operation == KEYSERVER_SEND) {
                String args = "--keyserver " + host + " --send-keys ";
                for (int i = 0; i < selected.length; i++) {
                    args += " " + Long.toHexString(selected[i]);
                }
                // TODO this should use the Java keyserver stuff
                GnuPG.gpg2(args);
            } else if (operation == KEYSERVER_RECEIVE) {
                String keys = "";
                for (int i = 0; i < selected.length; i++) {
                    try {
                        keys += keyserver.get(selected[i]);
                        keys += "\n\n";
                    } catch (QueryException e) {
                        e.printStackTrace();
                    }
                }
                // An Intent can carry very much data, so write it
                // to a cached file
                try {
                    File privateFile = File.createTempFile("keyserver", ".pkr", mCurrentActivity.getCacheDir());
                    FileUtils.writeStringToFile(privateFile, keys);
                    intent.setType(getString(R.string.pgp_keys));
                    intent.setAction(Intent.ACTION_SEND);
                    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(privateFile));
                } catch (IOException e) {
                    e.printStackTrace();
                    // try sending the key data inline in the Intent
                    intent.setType("text/plain");
                    intent.setAction(Intent.ACTION_SEND);
                    intent.putExtra(Intent.EXTRA_TEXT, keys);
                }
            }
            return null;
        }

        @Override
        protected void onPostExecute(Void v) {
            GpgApplication.triggerContactsSync();
            mCurrentActivity.setSupportProgressBarIndeterminateVisibility(false);
            mode.finish(); // Action picked, so close the CAB
            if (operation == KEYSERVER_RECEIVE)
                startActivity(intent);
        }
    }.execute();
}

From source file:nl.sogeti.android.gpstracker.actions.ShareTrack.java

private void sendFile(Uri fileUri, String body, String contentType) {
    Intent sendActionIntent = new Intent(Intent.ACTION_SEND);
    sendActionIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.email_subject));
    sendActionIntent.putExtra(Intent.EXTRA_TEXT, body);
    sendActionIntent.putExtra(Intent.EXTRA_STREAM, fileUri);
    sendActionIntent.setType(contentType);
    startActivity(Intent.createChooser(sendActionIntent, getString(R.string.sender_chooser)));
}

From source file:cn.ttyhuo.view.UserView.java

/**
 * //from ww  w. j  a  v  a 2  s  .c o m
 * @param context 
 * @param activityTitle Activity??
 * @param msgTitle ?
 * @param msgText ?
 * @param imgPath ?null
 */
public static void shareMsg(Context context, String activityTitle, String msgTitle, String msgText, File f) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    if (f == null || !f.exists() || !f.isFile()) {
        intent.setType("text/plain"); // 
    } else {
        intent.setType("image/png");
        Uri u = Uri.fromFile(f);
        //Uri u = Uri.parse(imgPath);
        intent.putExtra(Intent.EXTRA_STREAM, u);
    }
    intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle);
    intent.putExtra(Intent.EXTRA_TEXT, msgText);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(Intent.createChooser(intent, activityTitle));
}

From source file:com.mibr.android.intelligentreminder.INeedToo.java

@Override
public Dialog onCreateDialog(int id) {
    switch (id) {
    case DIALOG_REMINDER_CONTACTS_SERVICE_FAILED_LICENSING:
        AlertDialog.Builder buildersvc = new AlertDialog.Builder(this);
        buildersvc.setMessage(/*from   w w  w  .j a v  a  2  s.  c om*/
                "The Reminder Contact Service add-on that you've got installed is not a licensed version");
        buildersvc.setCancelable(false)
                .setNeutralButton(R.string.msg_cus, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        String[] mailto = { "info@intelligentreminder.com", "" };
                        Intent sendIntent = new Intent(Intent.ACTION_SEND);
                        sendIntent.putExtra(Intent.EXTRA_EMAIL, mailto);
                        sendIntent.putExtra(Intent.EXTRA_SUBJECT, "".toString());
                        sendIntent.putExtra(Intent.EXTRA_TEXT, "".toString());
                        sendIntent.setType("text/plain");
                        startActivity(Intent.createChooser(sendIntent, "Send EMail..."));
                    }
                }).setPositiveButton(R.string.msg_register, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {

                        if (INeedToo.IS_ANDROID_VERSION) {
                            String uri = getString(R.string.indeedtopayforservice);
                            Intent ii3 = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                            startActivity(ii3);
                        } else {
                            Uri uri = Uri.parse(
                                    "http://www.amazon.com/gp/mas/dl/android?p=com.mibr.android.remindercontacts");
                            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                            startActivity(intent);
                        }

                        isReminderContactsAvailable = true;
                        iDidReminderContacts = false;
                    }
                }).setNegativeButton(R.string.msg_cancel, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                    }
                });
        AlertDialog alert = buildersvc.create();
        return alert;

    case DOING_SAMPLE_NEEDS_DIALOG:
        if (allItems == null) {
            return null;
        }
        dialogDoingSamples = new Dialog(this);
        dialogDoingSamples.setOwnerActivity(this);
        dialogDoingSamples.setContentView(R.layout.ineedvoiceprogress);
        dialogDoingSamples.setTitle("Working ...");
        ((Button) dialogDoingSamples.findViewById(R.id.needvoiceprogress_cancel)).setEnabled(true);
        ((Button) dialogDoingSamples.findViewById(R.id.needvoiceprogress_ok)).setEnabled(false);
        ;
        //         dialogDoingSamples.show();
        ArrayList stuff = new ArrayList();
        stuff.add(dialogDoingSamples);
        stuff.add(getApplicationContext());
        stuff.add(this);
        stuff.add(getLocationManager());
        stuff.add(getDbAdapter());
        stuff.add(allItems.get(whereImAtInAllItems));
        stuff.add(new Integer(1));
        new NeedByVoiceProgress().execute(stuff);
        return dialogDoingSamples;

    case DIALOG_SAMPLES:
        Dialog aDialog = null;
        AlertDialog.Builder builder2;
        LayoutInflater inflater2 = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout2 = inflater2.inflate(R.layout.ineedsamples, (ViewGroup) findViewById(R.id.hijklmnop));
        builder2 = new AlertDialog.Builder(this);
        builder2.setView(layout2);
        builder2.setTitle("Build Sample Data Set");
        builder2.setPositiveButton("Okay", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                allItems = new ArrayList<ArrayList<String>>();
                Boolean doit = false;
                StringBuilder sb = new StringBuilder();
                StringBuilder sb2 = new StringBuilder();
                StringBuilder sb3 = new StringBuilder();
                int cnt = 0;
                Boolean dw = false;
                ArrayList<String> jdmatchesSS = null;
                ;
                sb.append("I need Print Cartridges description HP 28 and 48 ");
                if (mWalmart != null && mWalmart.isChecked()) {
                    sb.append(" location Walmart ");
                    dw = true;
                }
                if (mWalgreens != null && mWalgreens.isChecked()) {
                    sb.append(" location Walgreens ");
                    dw = true;
                }
                if (dw) { // they checked something
                    doit = true;
                    jdmatchesSS = new ArrayList<String>();
                    jdmatchesSS.add(sb.toString());
                    allItems.add(jdmatchesSS);
                    cnt++;
                }
                if (mSevenEleven != null && mSevenEleven.isChecked()) {
                    sb3.append("I need Energy Drink description Red Bull location 7-Eleven ");
                    ArrayList<String> jdmatches = new ArrayList<String>();
                    jdmatches.add(sb3.toString());
                    allItems.add(jdmatches);
                    cnt++;
                    doit = true;
                }

                if (mStarbucks != null && mStarbucks.isChecked()) {
                    sb2.append("I need Coffee description French Roast location Starbucks");
                    ArrayList<String> jdmatches = new ArrayList<String>();
                    jdmatches.add(sb2.toString());
                    allItems.add(jdmatches);
                    cnt++;
                    doit = true;
                }
                if (doit) {
                    whereImAtInAllItems = 0;
                    INeedToo.this.showDialog(DOING_SAMPLE_NEEDS_DIALOG);
                }

            }
        });
        mWalmart = (CheckBox) layout2.findViewById(R.id.BuildWalmart);
        mWalgreens = (CheckBox) layout2.findViewById(R.id.BuildWalgreens);
        mSevenEleven = (CheckBox) layout2.findViewById(R.id.Build7Eleven);
        mStarbucks = (CheckBox) layout2.findViewById(R.id.BuildStarbucks);

        aDialog = builder2.create();
        return aDialog;

    case DIALOG_SPLASH:
        /*
        jdd=new Dialog(mContext);
        jdd.setContentView(R.layout.ineed2splash);
        jdd.setTitle("W E L C O M E");
        */

        AlertDialog.Builder builder;
        LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
        View layout = inflater.inflate(R.layout.ineed2splashv2,
                (ViewGroup) findViewById(R.id.ScrollView01lmnop2));
        builder = new AlertDialog.Builder(this);

        builder.setPositiveButton("Okay", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                if (mWantSample != null) {
                    if (mWantSample.isChecked()) {
                        showDialog(DIALOG_SAMPLES);
                    }
                }
            }
        });
        builder.setTitle("W E L C O M E");
        if (getDbAdapter().thereAreSomeLocationsOnSystem()) {
            LinearLayout ll = (LinearLayout) layout.findViewById(R.id.CreateDefaultValues);
            ll.setVisibility(View.INVISIBLE);
        } else {
            mWantSample = (CheckBox) layout.findViewById(R.id.BuildDefaultValues);
        }
        builder.setView(layout);
        jdd = builder.create();
        //Button butt=(Button)jdd.findViewById(R.id.Button01);
        /*butt.setOnClickListener(new View.OnClickListener() {
                   
           @Override
           public void onClick(View v) {
              jdd.cancel();
           }
        });
        */
        break;
    default:
        return null;
    }
    return jdd;

}

From source file:com.github.gorbin.asne.instagram.InstagramSocialNetwork.java

/**
 * Post photo to social network//from  w ww .  j  a v a  2 s.c  o m
 * @param photo photo that should be shared
 * @param message message that should be shared with photo
 * @param onPostingCompleteListener listener for posting request
 */
@Override
public void requestPostPhoto(File photo, String message, OnPostingCompleteListener onPostingCompleteListener) {
    super.requestPostPhoto(photo, message, onPostingCompleteListener);
    String instagramPackage = "com.instagram.android";
    String errorMessage = "You should install Instagram app first";
    if (isPackageInstalled(instagramPackage, mSocialNetworkManager.getActivity())) {
        Intent normalIntent = new Intent(Intent.ACTION_SEND);
        normalIntent.setType("image/*");
        normalIntent.setPackage(instagramPackage);
        File media = new File(photo.getAbsolutePath());
        Uri uri = Uri.fromFile(media);
        normalIntent.putExtra(Intent.EXTRA_STREAM, uri);
        normalIntent.putExtra(Intent.EXTRA_TEXT, message);
        mSocialNetworkManager.getActivity().startActivity(normalIntent);
    } else {
        mLocalListeners.get(REQUEST_POST_PHOTO).onError(getID(), REQUEST_POST_PHOTO, errorMessage, null);
    }
    mLocalListeners.remove(REQUEST_POST_PHOTO);
}