Example usage for android.content Intent EXTRA_SUBJECT

List of usage examples for android.content Intent EXTRA_SUBJECT

Introduction

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

Prototype

String EXTRA_SUBJECT

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

Click Source Link

Document

A constant string holding the desired subject line of a message.

Usage

From source file:com.mbientlab.metawear.app.AccelerometerFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    checkboxes = new HashMap<>();
    checkboxes.put(CheckBoxName.TAP, (CheckBox) view.findViewById(R.id.checkBox1));
    checkboxes.put(CheckBoxName.SHAKE, (CheckBox) view.findViewById(R.id.checkBox2));
    checkboxes.put(CheckBoxName.ORIENTATION, (CheckBox) view.findViewById(R.id.checkBox3));
    checkboxes.put(CheckBoxName.FREE_FALL, (CheckBox) view.findViewById(R.id.checkBox4));
    checkboxes.put(CheckBoxName.SAMPLING, (CheckBox) view.findViewById(R.id.checkBox5));

    ((Button) view.findViewById(R.id.button3)).setOnClickListener(new OnClickListener() {
        @Override/*from  www .  jav  a  2  s  .  co  m*/
        public void onClick(View arg0) {
            if (mwMnger.controllerReady()) {
                accelController.stopComponents();
                accelController.disableAllDetection(true);
                for (CheckBox box : checkboxes.values()) {
                    box.setEnabled(true);
                }

            } else {
                Toast.makeText(getActivity(), R.string.error_connect_board, Toast.LENGTH_LONG).show();
            }
        }
    });
    ((Button) view.findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            if (mwMnger.controllerReady()) {
                if (checkboxes.get(CheckBoxName.TAP).isChecked()) {
                    accelController.enableTapDetection(TapType.values()[accelConfig.tapTypePos()],
                            Axis.values()[accelConfig.tapAxisPos()]);
                }
                if (checkboxes.get(CheckBoxName.SHAKE).isChecked()) {
                    accelController.enableShakeDetection(Axis.values()[accelConfig.shakeAxisPos()]);
                }
                if (checkboxes.get(CheckBoxName.ORIENTATION).isChecked()) {
                    accelController.enableOrientationDetection();
                }
                if (checkboxes.get(CheckBoxName.FREE_FALL).isChecked()) {
                    if (accelConfig.movementPos() == 0) {
                        accelController.enableFreeFallDetection();
                    } else {
                        accelController.enableMotionDetection(Axis.values());
                    }
                }
                if (checkboxes.get(CheckBoxName.SAMPLING).isChecked()) {
                    rmsValues = new Vector<>();
                    SamplingConfig config = accelController.enableXYZSampling();
                    config.withFullScaleRange(FullScaleRange.values()[accelConfig.fsrPos()])
                            .withOutputDataRate(OutputDataRate.values()[accelConfig.odrPos()]);
                    accelConfig.initialize(config.getBytes());
                    start = 0;
                }
                accelController.startComponents();

                for (CheckBox box : checkboxes.values()) {
                    box.setEnabled(false);
                }
            } else {
                Toast.makeText(getActivity(), R.string.error_connect_board, Toast.LENGTH_LONG).show();
            }
        }
    });
    ((Button) view.findViewById(R.id.button2)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            final FragmentManager fm = getActivity().getSupportFragmentManager();
            final AccelerometerSettings dialog = new AccelerometerSettings();

            dialog.show(fm, "accelerometer_settings");
        }
    });
    ((Button) view.findViewById(R.id.textView10)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (accelConfig.polledBytes() == null) {
                Toast.makeText(getActivity(), R.string.error_no_accel_data, Toast.LENGTH_SHORT).show();
            } else {
                final FragmentManager fm = getActivity().getSupportFragmentManager();
                final DataPlotFragment dialog = new DataPlotFragment();

                dialog.show(fm, "resistance_graph_fragment");
            }
        }
    });
    ((Button) view.findViewById(R.id.textView11)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (accelConfig.polledBytes() == null) {
                Toast.makeText(getActivity(), R.string.error_no_accel_data, Toast.LENGTH_SHORT).show();
            } else {
                writeDataToFile();

                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("text/plain");
                intent.putExtra(Intent.EXTRA_SUBJECT, "Logged Accelerometer Data");

                File file = getActivity().getFileStreamPath(dataFilename);
                Uri uri = FileProvider.getUriForFile(getActivity(), "com.mbientlab.metawear.app.fileprovider",
                        file);
                intent.putExtra(Intent.EXTRA_STREAM, uri);
                startActivity(Intent.createChooser(intent, "Send email..."));
            }
        }
    });
}

From source file:com.support.android.designlibdemo.activities.CampaignDetailActivity.java

public void setupShareIntent() {
    // Fetch Bitmap Uri locally
    ImageView ivImage = (ImageView) findViewById(R.id.ivCampaighnImage);
    // Get access to the URI for the bitmap
    Uri bmpUri = getLocalBitmapUri(ivImage);
    if (bmpUri != null) {
        // Construct a ShareIntent with link to image
        Intent shareIntent = new Intent();
        shareIntent.setAction(Intent.ACTION_SEND);
        shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri);
        shareIntent.putExtra(Intent.EXTRA_SUBJECT, campaign.getTitle());
        shareIntent.putExtra(Intent.EXTRA_TEXT, campaign.getCampaignUrl());
        shareIntent.setType("image/*");
        // Launch sharing dialog for image
        startActivity(Intent.createChooser(shareIntent, "send"));
    } else {//from  w  w  w  . ja v a2s . com
        Toast.makeText(this, "Some error occured during sharing", Toast.LENGTH_LONG).show();

    }

}

From source file:com.danvelazco.fbwrapper.activity.BaseFacebookWebViewActivity.java

/**
 * Allows us to share the page that's currently opened
 * using the ACTION_SEND share intent./*from w w w. j ava 2  s  .c  o m*/
 */
protected void shareCurrentPage() {
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("text/plain");
    i.putExtra(Intent.EXTRA_SUBJECT, R.string.share_action_subject);
    i.putExtra(Intent.EXTRA_TEXT, mWebView.getUrl());
    startActivity(Intent.createChooser(i, getString(R.string.share_action)));
}

From source file:com.readystatesoftware.ghostlog.LogService.java

@Override
public void onLogShare() {
    StringBuffer sb = new StringBuffer();
    for (LogLine line : mLogBufferFiltered) {
        sb.append(line.getRaw());/*from  ww  w  .j a v  a2s .  com*/
        sb.append("\n");
    }
    Time now = new Time();
    now.setToNow();
    String ts = now.format3339(false);

    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, sb.toString());
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_subject) + " " + ts);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivity(shareIntent);
}

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
 *//*  w  w w . j  a v  a2 s. c  o m*/
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:com.antew.redditinpictures.library.ui.ImageViewerActivity.java

/**
 * Handler for when the user selects an item from the ActionBar.
 * <p>/*w  w  w . j  a v  a2s . 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.murrayc.galaxyzoo.app.SubjectFragment.java

private void updateShareActionIntent() {
    /**/*from w ww .jav a  2  s. c  o m*/
     * Initialization and setup of the share intent is done here so that less work is left after the AsyncTask's execution
     */
    if (mShareActionProvider == null) {
        Log.error("updateShareActionIntent(): mShareActionProvider is null.");
        return;
    }

    final Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "A Galaxy Zoo image.");
    //Only useful with ACTION_CHOOSER: shareIntent.putExtra(Intent.EXTRA_TITLE, "Share the Galaxy Zoo image.");

    final String uri = Utils.getTalkUri(getZooniverseId());
    if (!TextUtils.isEmpty(uri)) {
        shareIntent.putExtra(Intent.EXTRA_TEXT, uri);
        shareIntent.setType("text/plain");
    }

    //TODO: This doesn't seem to work, maybe because the other app wouldn't have access to our
    //content provider?
    //shareIntent.putExtra(Intent.EXTRA_STREAM, mUriImageStandard);
    //shareIntent.setType("image/*");

    /**
     * if the image URI is not null, a GetImageBitmapAsyncTask is executed for it, and the returned URI is set as
     * a stream extra on the intent that will be shared, along with an explicit permission for recieving contexts to
     * read the content URI, enabling them to access the generated image.
     */
    if (mUriStandardRemote != null) {
        GetImageBitmapAsyncTask getImageBitmapAsyncTask = new GetImageBitmapAsyncTask() {
            @Override
            protected void onPostExecute(Uri uri) {
                shareIntent.setType("image/*");
                shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
                shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                mShareActionProvider.setShareIntent(shareIntent);
            }
        };
        getImageBitmapAsyncTask.execute(mUriStandardRemote);
    }

}

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:com.nikhilnayak.games.octoshootar.HomeActivity.java

@Override
public void onShareScoreRequested(long score) {
    Intent intent = new Intent(android.content.Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
    intent.putExtra(Intent.EXTRA_SUBJECT, getResources().getString(R.string.score_share_subject));
    intent.putExtra(Intent.EXTRA_TEXT, getResources().getString(R.string.score_share_content, score));
    startActivity(Intent.createChooser(intent, getResources().getString(R.string.score_share_dialog)));
}