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:ca.rmen.android.networkmonitor.app.dbops.ui.Share.java

/**
 * Run the given file export, then bring up the chooser intent to share the exported file.
 * The progress will be displayed in a progress dialog on the given activity.
 *//*from  w w  w.ja  v a  2 s .co m*/
private static void shareFile(final FragmentActivity activity, final FileExport fileExport) {
    Log.v(TAG, "shareFile " + fileExport);

    Bundle bundle = new Bundle(1);
    bundle.putString(DBOpAsyncTask.EXTRA_DIALOG_MESSAGE,
            activity.getString(R.string.export_progress_preparing_export));
    new DBOpAsyncTask<File>(activity, fileExport, bundle) {

        @Override
        protected File doInBackground(Void... params) {
            Log.v(TAG, "doInBackground");
            File file = null;
            if (fileExport != null) {
                if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))
                    return null;
                file = super.doInBackground(params);
                if (file == null)
                    return null;
            }

            String reportSummary = SummaryExport.getSummary(activity);
            // Bring up the chooser to share the file.
            Intent sendIntent = new Intent();
            sendIntent.setAction(Intent.ACTION_SEND);
            sendIntent.putExtra(Intent.EXTRA_SUBJECT, activity.getString(R.string.export_subject_send_log));

            String dateRange = SummaryExport.getDataCollectionDateRange(activity);

            String messageBody = activity.getString(R.string.export_message_text, dateRange);
            if (file != null) {
                sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getAbsolutePath()));
                sendIntent.setType("message/rfc822");
                messageBody += activity.getString(R.string.export_message_text_file_attached);
            } else {
                sendIntent.setType("text/plain");
            }
            messageBody += reportSummary;
            sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody);

            activity.startActivity(
                    Intent.createChooser(sendIntent, activity.getResources().getText(R.string.action_share)));
            return file;
        }

        @Override
        protected void onPostExecute(File result) {
            Log.v(TAG, "onPostExecute");
            // Show a toast if we failed to export a file.
            if (fileExport != null && result == null)
                Toast.makeText(activity, R.string.export_error_sdcard_unmounted, Toast.LENGTH_LONG).show();
            super.onPostExecute(result);
        }
    }.execute();
}

From source file:com.Bhailal_Chauhan.retailapp.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   ww w  .j a v  a2  s .c o m*/

    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:" + "8347337366"));
            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://bhailalchauhan.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[] { "hibhailal458@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:codepath.watsiapp.utils.Util.java

public static void startShareIntent(Activity activity, ShareableItem patient) {
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_TEXT, patient.getShareableUrl());
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Fund Treatment");
    activity.startActivity(Intent.createChooser(shareIntent, "Share Story"));
}

From source file:com.judepereira.android.co.uncyclopedia.UncyclopediaActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.share:
        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        String shareBody = "Hey,\n" + "Check out this article on Uncyclopedia: \n\n" + wikiView.getTitle()
                + "\n" + history.peek().getUrl() + "\n\nSent via the Uncyclopedia App for Android";
        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, wikiView.getTitle());
        sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
        startActivity(Intent.createChooser(sharingIntent, "Share via"));
        break;//from   ww  w.j  a  va2 s. co m
    case R.id.exit:
        finish();
        break;
    case R.id.save:
        ArticleHistory article = history.peek();
        if (bookmarkArticle(wikiView.getTitle(), article.getUrl())) {
            Toast.makeText(this, "Successfully bookmarked", Toast.LENGTH_LONG).show();
        } else {
            Toast.makeText(this, "An error occured. please try again", Toast.LENGTH_LONG).show();
        }
        break;
    case R.id.saved:
        FragmentManager fragmentManager = getSupportFragmentManager();
        BookmarksDialog dFrag = new BookmarksDialog();
        dFrag.setContext(this);
        dFrag.setWikiView(wikiView);
        dFrag.setClient(client);
        dFrag.show(fragmentManager, "Bookmarks");
        break;
    }
    return true;
}

From source file:com.github.akinaru.roboticbuttonpusher.menu.MenuUtils.java

/**
 * Execute actions according to selected menu item
 *
 * @param menuItem MenuItem object//from  w  w  w  .  j  av a 2  s .com
 * @param mDrawer  navigation drawer
 * @param context  android context
 */
public static void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context,
        final IButtonPusher buttonPusher) {

    switch (menuItem.getItemId()) {
    case R.id.exit_item: {
        if (buttonPusher.giveUpNoPermission()) {
            buttonPusher.disassociate();
        } else {
            buttonPusher.requestPermission();
        }
        break;
    }
    case R.id.password_item: {
        if (buttonPusher != null) {
            if (buttonPusher.giveUpNoPermission()) {
                DevicePasswordDialog dialog = new DevicePasswordDialog(buttonPusher);
                dialog.show();
            } else {
                buttonPusher.requestPermission();
            }
        }
        break;
    }
    case R.id.keys_item: {
        if (buttonPusher != null) {
            if (buttonPusher.giveUpNoPermission()) {
                KeysDialog dialog = new KeysDialog(buttonPusher);
                dialog.show();
            } else {
                buttonPusher.requestPermission();
            }
        }
        break;
    }
    case R.id.message_item: {
        if (buttonPusher != null) {
            if (buttonPusher.giveUpNoPermission()) {
                DeviceMessageDialog dialog = new DeviceMessageDialog(buttonPusher);
                dialog.show();
            } else {
                buttonPusher.requestPermission();
            }
        }
        break;
    }
    case R.id.debug_mode_item: {

        CharSequence[] array = { "enabled", "disabled" };

        int indexCheck = buttonPusher.getDebugMode() ? 0 : 1;

        new AlertDialog.Builder(context).setSingleChoiceItems(array, indexCheck, null)
                .setPositiveButton(buttonPusher.getContext().getResources().getString(R.string.dialog_ok),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                dialog.dismiss();
                                int selectedPosition = ((AlertDialog) dialog).getListView()
                                        .getCheckedItemPosition();
                                if (selectedPosition == 0) {
                                    buttonPusher.setDebugMode(true);
                                } else {
                                    buttonPusher.setDebugMode(false);
                                }
                            }
                        })
                .setNegativeButton(buttonPusher.getContext().getResources().getString(R.string.cancel),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int whichButton) {
                                dialog.dismiss();
                            }
                        })
                .show();
        break;
    }
    case R.id.report_bugs: {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", context.getResources().getString(R.string.email_addr), null));
        intent.putExtra(Intent.EXTRA_SUBJECT, context.getResources().getString(R.string.issue_subject));
        intent.putExtra(Intent.EXTRA_TEXT, context.getResources().getString(R.string.report_hint));
        context.startActivity(
                Intent.createChooser(intent, context.getResources().getString(R.string.issue_title)));
        break;
    }
    case R.id.open_source_components: {
        OpenSourceItemsDialog d = new OpenSourceItemsDialog(context);
        d.show();
        break;
    }
    case R.id.rate_app: {
        context.startActivity(new Intent(Intent.ACTION_VIEW,
                Uri.parse("market://details?id=" + context.getApplicationContext().getPackageName())));
        break;
    }
    case R.id.about_app: {
        AboutDialog dialog = new AboutDialog(context);
        dialog.show();
        break;
    }
    }
    mDrawer.closeDrawers();
}

From source file:com.anysoftkeyboard.ui.SendBugReportUiActivity.java

public void onSendCrashReport(View v) {
    String[] recipients = new String[] { BuildConfig.CRASH_REPORT_EMAIL_ADDRESS };

    Intent sendMail = new Intent();
    sendMail.setAction(Intent.ACTION_SEND);
    sendMail.setType("plain/text");
    sendMail.putExtra(Intent.EXTRA_EMAIL, recipients);
    sendMail.putExtra(Intent.EXTRA_SUBJECT, getText(R.string.ime_crashed_title));
    sendMail.putExtra(Intent.EXTRA_TEXT, mCrashReportDetails.crashReportText);

    try {//w  w w .j av a2 s . com
        Intent sender = Intent.createChooser(sendMail, getString(R.string.ime_crashed_intent_selector_title));
        sender.putExtra(Intent.EXTRA_EMAIL, sendMail.getStringArrayExtra(Intent.EXTRA_EMAIL));
        sender.putExtra(Intent.EXTRA_SUBJECT, sendMail.getStringExtra(Intent.EXTRA_SUBJECT));
        sender.putExtra(Intent.EXTRA_TEXT, mCrashReportDetails.crashReportText);

        Log.i(TAG, "Will send crash report using " + sender);
        startActivity(sender);
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(getApplicationContext(), "Unable to send bug report via e-mail!", Toast.LENGTH_LONG)
                .show();
    }

    finish();
}

From source file:com.github.akinaru.hcidebugger.activity.BaseActivity.java

protected void setSharedIntent() {
    File sharedFile = new File(mBtSnoopFilePath);

    String object = "HCI report " + timestampFormat.format(new Date().getTime());

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, object);
    intent.putExtra(Intent.EXTRA_TEXT, object);
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(sharedFile));

    mShareActionProvider.setShareIntent(intent);
}

From source file:de.appplant.cordova.emailcomposer.EmailComposerImpl.java

/**
 * Setter for the subject./*  ww  w.j  av a  2s.c  om*/
 *
 * @param subject
 * The subject of the email.
 * @param draft
 * The intent to send.
 */
private void setSubject(String subject, Intent draft) {
    draft.putExtra(Intent.EXTRA_SUBJECT, subject);
}

From source file:com.normalexception.app.rx8club.preferences.Preferences.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getPreferenceManager().setSharedPreferencesName(PreferenceHelper.PREFS_NAME);
    addPreferencesFromResource(R.xml.preferences);

    Preference shareLog = (Preference) findPreference("exportLog");
    shareLog.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override//  w w w  .  j a v a 2 s. c  o m
        public boolean onPreferenceClick(Preference preference) {
            String user = UserProfile.getInstance().getUsername();
            if (user.equals(""))
                user = "Guest";

            // We need to create an intent here for sharing
            Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);

            // The intent type is a text type
            sharingIntent.setType("message/rfc822");

            // Add email details
            sharingIntent.putExtra(Intent.EXTRA_EMAIL,
                    new String[] { getResources().getString(R.string.bug_contact) });
            sharingIntent.putExtra(Intent.EXTRA_SUBJECT, "RX8Club.com Log: " + user);

            // Open the file
            Uri uri = Uri.fromFile(new File(LogFile.getLogFile()));

            // Add the file to the intent
            sharingIntent.putExtra(Intent.EXTRA_STREAM, uri);

            // Start the intent
            try {
                startActivity(
                        Intent.createChooser(sharingIntent, getResources().getString(R.string.sendEmail)));
            } catch (android.content.ActivityNotFoundException ex) {
                Toast.makeText(MainApplication.getAppContext(), R.string.noEmail, Toast.LENGTH_SHORT).show();
            }

            return true;
        }
    });

    Preference threadFilter = (Preference) findPreference("threadFilter");
    threadFilter.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference arg0) {
            //startActivity(
            //      new Intent(MainApplication.getAppContext(), ThreadFilterFragment.class));
            // Create new fragment and transaction
            Fragment newFragment = new ThreadFilterFragment();
            FragmentTransaction transaction = getFragmentManager().beginTransaction();

            // Replace whatever is in the fragment_container view with this fragment,
            // and add the transaction to the back stack
            transaction.add(R.id.content_frame, newFragment);
            transaction.addToBackStack("threadfilter");

            // Commit the transaction
            transaction.commit();
            return true;
        }
    });

    Preference customAdv = (Preference) findPreference("customSig");
    customAdv.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference arg0) {
            SignatureDialog sd = new SignatureDialog(getActivity());
            sd.show();
            return true;
        }
    });

    Preference man_fave = (Preference) findPreference("manage_favorites");
    man_fave.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference arg0) {
            if (FavoriteFactory.getInstance().getCount() > 0) {
                FavoriteDialog fd = new FavoriteDialog(getActivity());
                fd.registerToRemove();
                fd.show();
            } else {
                notifyError("No Favorites Defined Yet!");
            }
            return true;
        }
    });

    final Preference cache = (Preference) findPreference("appcache");
    cache.setSummary(String.format("Cache Size: %s",
            SpecialNumberFormatter.readableFileSize((new Cache(getActivity())).getCacheSize())));
    cache.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference arg0) {
            new AsyncTask<Void, String, Void>() {
                ProgressDialog loadingDialog;

                @Override
                protected void onPreExecute() {

                    loadingDialog = ProgressDialog.show(getActivity(), getString(R.string.dialogClearingCache),
                            getString(R.string.pleaseWait), true);
                }

                @Override
                protected Void doInBackground(Void... params) {
                    try {
                        (new FileCache(getActivity())).clear();
                    } catch (Exception e) {
                    }
                    return null;
                }

                @Override
                protected void onPostExecute(Void result) {
                    try {
                        loadingDialog.dismiss();
                        loadingDialog = null;
                    } catch (Exception e) {
                        Log.w(TAG, e.getMessage());
                    }

                    cache.setSummary(String.format("Cache Size: %s", SpecialNumberFormatter
                            .readableFileSize((new Cache(getActivity())).getCacheSize())));
                    Toast.makeText(getActivity(), R.string.dialogCacheCleared, Toast.LENGTH_SHORT).show();
                }
            }.execute();
            return true;
        }
    });

    Preference rate = (Preference) findPreference("rate");
    rate.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
        @Override
        public boolean onPreferenceClick(Preference arg0) {
            try {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse(WebUrls.marketUrl + MainApplication.APP_PACKAGE)));
            } catch (ActivityNotFoundException e) {
                // In the event that the market isn't installed
                // or is unavailable
                notifyError("Error Opening Market, Sorry!");
            }
            return true;
        }
    });

    try {
        Preference version = (Preference) findPreference("version");
        version.setSummary(getActivity().getPackageManager().getPackageInfo(getActivity().getPackageName(),
                0).versionName);
    } catch (Exception e) {
    }

    try {
        Preference build = (Preference) findPreference("build");
        build.setSummary(Integer.toString(getActivity().getPackageManager()
                .getPackageInfo(getActivity().getPackageName(), 0).versionCode));
    } catch (Exception e) {
    }
}

From source file:edu.mit.mobile.android.demomode.Preferences.java

private void shareConfig() {
    startActivity(Intent.createChooser(/*from  w  ww .  j  a  v a  2  s  . c o  m*/
            new Intent(Intent.ACTION_SEND).setType("text/plain").putExtra(Intent.EXTRA_TEXT, toConfigString())
                    .putExtra(Intent.EXTRA_SUBJECT, getText(R.string.app_name) + " Config"),
            getText(R.string.share_config)));
}