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.kyat.DJbooth.MainActivity.java

public void reportBug(View reportBug) {
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("message/rfc822");
    i.putExtra(Intent.EXTRA_EMAIL, new String[] { getResources().getString(R.string.contactEmail) });
    i.putExtra(Intent.EXTRA_SUBJECT, "RMT Tools Feedback");
    i.putExtra(Intent.EXTRA_TEXT, "Your feedback here...");
    try {/*from   w w  w. jav a2  s  .c om*/
        startActivity(Intent.createChooser(i, "Send Feedback"));
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(this, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
    }
}

From source file:com.justplay1.shoppist.shared.base.fragments.BaseFragment.java

protected void share(String textToSend, String header) {
    Intent sendIntent = new Intent();
    sendIntent.setAction(Intent.ACTION_SEND);
    sendIntent.putExtra(Intent.EXTRA_TEXT, textToSend);
    sendIntent.putExtra(Intent.EXTRA_SUBJECT, header);
    sendIntent.setType("text/plain");
    startActivity(Intent.createChooser(sendIntent, getString(R.string.send_to)));
}

From source file:ca.ualberta.slevinsk.gameshow.StatsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_stats);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);//from  ww  w . j a  v a2s .com

    ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
    viewPager.setAdapter(new StatsFragmentPagerAdapter(getSupportFragmentManager(), StatsActivity.this));

    TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
    tabLayout.setupWithViewPager(viewPager);

    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    ReactionTimersManager.initManager(getApplicationContext());
    BuzzerCounterManager.initManager(getApplicationContext());

    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/rfc822");
            intent.putExtra(Intent.EXTRA_SUBJECT, "slevinsk - stats");
            intent.putExtra(Intent.EXTRA_TEXT,
                    BuzzerCounterController.generateEmailData() + ReactionTimersController.generateEmailData());

            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) {
                Snackbar.make(view, "There is no email client installed", Snackbar.LENGTH_LONG).show();
            }

        }
    });

}

From source file:com.kyakujin.android.tagnotepad.ui.NoteActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    Intent intent = getIntent();/*from  w  w  w .j a v a 2 s  .  co m*/
    String action = intent.getAction();
    // DBG
    //  FragmentManager.enableDebugLogging(true);
    //  Log.d("debug", "ActivityTest: onCreate start"); // DBG

    // ?????????NoteEditFragment??????
    if (Intent.ACTION_SEND.equals(action)) {
        Bundle extras = intent.getExtras();

        if (extras != null) {
            String extBody = extras.getString(Intent.EXTRA_TEXT);
            String extTitle = extras.getString(Intent.EXTRA_SUBJECT);
            Bundle bundle = new Bundle();
            if (extBody != null) {
                bundle.putString(Config.SHARED_BODY, extBody);
            }
            if (extTitle != null) {
                bundle.putString(Config.SHARED_TITLE, extTitle);
            }

            bundle.putInt("action", Config.ACTION_SENDED);
            Fragment fg = NoteEditFragment.newInstance();
            FragmentManager manager = getSupportFragmentManager();
            FragmentTransaction transaction = manager.beginTransaction();
            fg.setArguments(bundle);
            transaction.add(android.R.id.content, fg, Config.TAG_NOTEEDIT_FRAGM);
            transaction.commit();
        }
    } else {
        Fragment fg = NoteListFragment.newInstance();
        if (!fg.isAdded()) {
            // NoteListFragment?????
            FragmentManager fm = getSupportFragmentManager();
            for (int i = 0; i < fm.getBackStackEntryCount(); i++) {
                fm.popBackStack();
            }

            getSupportFragmentManager().beginTransaction()
                    .replace(android.R.id.content, fg, Config.TAG_NOTELIST_FRAGM).commit();
        }
    }

    handleIntent(getIntent());
}

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

/**
 * Execute actions according to selected menu item
 *
 * @param menuItem MenuItem object/* ww w  .j av  a 2  s  .c om*/
 * @param mDrawer  navigation drawer
 */
public static void selectDrawerItem(MenuItem menuItem, DrawerLayout mDrawer, Context context,
        final IHciDebugger activity, IDialog dialogCb) {

    switch (menuItem.getItemId()) {
    case R.id.set_max_packet_num: {
        if (activity != null) {
            MaxPacketCountDialog dialog = new MaxPacketCountDialog(activity);
            dialogCb.setCurrentDialog(dialog);
            dialog.show();
        }
        break;
    }
    case R.id.browse_file: {
        if (activity != null) {
            SnoopFileDialog dialog = new SnoopFileDialog(activity);
            dialogCb.setCurrentDialog(dialog);
            dialog.show();
        }
        break;
    }
    case R.id.report_bugs: {
        Intent intent = new Intent(Intent.ACTION_SENDTO,
                Uri.fromParts("mailto", context.getResources().getString(R.string.developper_mail), null));
        intent.putExtra(Intent.EXTRA_SUBJECT, context.getResources().getString(R.string.issue_object));
        intent.putExtra(Intent.EXTRA_TEXT, context.getResources().getString(R.string.issue_message));
        context.startActivity(
                Intent.createChooser(intent, context.getResources().getString(R.string.issue_title)));
        break;
    }
    case R.id.scan_btn_nv: {
        activity.toggleScan(menuItem);
        break;
    }
    case R.id.reset_snoop_file_nv: {
        activity.resetSnoopFile();
        activity.refresh();
        break;
    }
    case R.id.state_bt_btn_nv: {
        activity.toggleBtState();
        break;
    }
    case R.id.change_settings: {

        CharSequence[] array = { "Classic/BLE scan", "BLE scan" };

        int indexCheck = 0;
        if (activity.getScanType() == ScanType.BLE_SCAN) {
            indexCheck = 1;
        }

        Dialog dialog = new AlertDialog.Builder(context).setSingleChoiceItems(array, indexCheck, null)
                .setPositiveButton("OK", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.dismiss();
                        int selectedPosition = ((AlertDialog) dialog).getListView().getCheckedItemPosition();
                        if (selectedPosition == 0) {
                            activity.setScanType(ScanType.CLASSIC_SCAN);
                        } else {
                            activity.setScanType(ScanType.BLE_SCAN);
                        }
                    }
                }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.dismiss();
                    }
                }).show();
        dialogCb.setCurrentDialog(dialog);
        break;
    }
    case R.id.open_source_components: {
        OpenSourceItemsDialog dialog = new OpenSourceItemsDialog(context);
        dialogCb.setCurrentDialog(dialog);
        dialog.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);
        dialogCb.setCurrentDialog(dialog);
        dialog.show();
        break;
    }
    }
    mDrawer.closeDrawers();
}

From source file:com.sbgapps.scoreit.fragments.InfoFragment.java

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

    PackageManager pm = getActivity().getPackageManager();
    String packageName = getActivity().getPackageName();
    String version;/*from   w w  w . j  av a  2s.co  m*/
    try {
        PackageInfo info = pm.getPackageInfo(packageName, 0);
        version = info.versionName;
    } catch (PackageManager.NameNotFoundException e) {
        version = VERSION_UNAVAILABLE;
    }
    version = getActivity().getString(R.string.app_name) + " " + version;
    TextView nameAndVersionView = (TextView) view.findViewById(R.id.version);
    nameAndVersionView.setText(version);

    Button btn;

    btn = (Button) view.findViewById(R.id.btn_contact);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("message/rfc822");
            intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "stephane@baiget.fr" });
            intent.putExtra(Intent.EXTRA_SUBJECT, "Score It");
            try {
                startActivity(intent);
            } catch (ActivityNotFoundException e) {
            }
        }
    });

    btn = (Button) view.findViewById(R.id.btn_rate);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Uri uri = Uri.parse("market://details?id=" + getActivity().getPackageName());
            Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
            try {
                startActivity(goToMarket);
            } catch (ActivityNotFoundException e) {
                startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(
                        "http://play.google.com/store/apps/details?id=" + getActivity().getPackageName())));
            }
        }
    });

    btn = (Button) view.findViewById(R.id.btn_share);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.putExtra(Intent.EXTRA_TEXT,
                    "http://play.google.com/store/apps/details?id=" + getActivity().getPackageName());
            startActivity(intent);
        }
    });

    btn = (Button) view.findViewById(R.id.btn_community);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://plus.google.com/u/0/communities/111590957716888215587"));
            startActivity(intent);
        }
    });

    btn = (Button) view.findViewById(R.id.btn_translate);
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://crowdin.net/project/score-it"));
            startActivity(intent);
        }
    });
    return view;
}

From source file:com.idt.ontomedia.geoconsum.BaseActivity.java

@Override
public boolean onMenuItemSelected(int _featureId, MenuItem _item) {
    switch (_item.getItemId()) {
    case REPORT_BUG_ITEM_ID: {
        final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
        emailIntent.setType("plain/text");
        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL,
                new String[] { this.getResources().getString(R.string.report_bug_emailto) });
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                this.getResources().getString(R.string.report_bug_subject));
        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                mErrorInfo + this.getResources().getString(R.string.report_bug_body));
        this.startActivity(
                Intent.createChooser(emailIntent, this.getResources().getString(R.string.report_bug_selector)));

        break;//  ww  w.  ja v  a 2s. c om
    }
    case ABOUT_ITEM_ID: {
        showDialog(DIALOG_ABOUT_ID);
        break;
    }
    case PREFERENCES_ITEM_ID: {
        startActivity(new Intent(this, DialogPreferenceActivity.class));
        break;
    }
    }
    return super.onMenuItemSelected(_featureId, _item);
}

From source file:com.granita.contacticloudsync.ui.DebugInfoActivity.java

public void onShare(MenuItem item) {
    if (!TextUtils.isEmpty(report)) {
        Intent sendIntent = new Intent();
        sendIntent.setAction(Intent.ACTION_SEND);
        sendIntent.setType("text/plain");
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Exception Details");

        try {/*from www .  jav a 2 s  .  c  om*/
            File reportFile = File.createTempFile("debug", ".txt", getExternalCacheDir());
            Constants.log.debug("Writing debug info to " + reportFile.getAbsolutePath());
            FileWriter writer = new FileWriter(reportFile);
            writer.write(report);
            writer.close();

            sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(reportFile));
        } catch (IOException e) {
            // let's hope the report is < 1 MB
            sendIntent.putExtra(Intent.EXTRA_TEXT, report);
        }

        startActivity(sendIntent);
    }
}

From source file:org.geek.utils.ApplicationUtils.java

/**
 * Share a page.// ww  w  .ja  va2s  . c o m
 * @param activity The parent activity.
 * @param title The page title.
 * @param url The page url.
 */
public static void sharePage(Activity activity, String title, String url) {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);

    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, url);
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, title);

    try {
        activity.startActivity(
                Intent.createChooser(shareIntent, activity.getString(R.string.Main_ShareChooserTitle)));
    } catch (android.content.ActivityNotFoundException ex) {
        // if no app handles it, do nothing
    }
}

From source file:com.coinblesk.client.ui.dialogs.ReceiveDialogFragment.java

@Nullable
@Override/*from   ww w . j a  va  2 s  .c o m*/
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    final String bitcoinUriString = this.getArguments().getString(BITCOIN_URI_KEY);

    try {
        final BitcoinURI bitcoinURI = new BitcoinURI(bitcoinUriString);
        final View view = inflater.inflate(R.layout.fragment_receive_alertdialog, null);
        view.findViewById(R.id.receive_email_touch_area).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                emailIntent.setType("text/html");
                emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,
                        String.format(getString(R.string.payment_request_html_subject)));
                emailIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                        Html.fromHtml(String.format(getString(R.string.payment_request_html_content),
                                bitcoinUriString, bitcoinURI.getAmount().toFriendlyString(),
                                bitcoinURI.getAddress())));
                startActivity(Intent.createChooser(emailIntent, "Email:"));
            }
        });

        view.findViewById(R.id.receive_qrcode_touch_area).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                QrDialogFragment.newInstance(bitcoinURI).show(getFragmentManager(), "qr-fragment");
            }
        });

        view.findViewById(R.id.receive_contactless_touch_area).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent action = new Intent(Constants.START_SERVERS_ACTION);
                action.putExtra(BITCOIN_URI_KEY, bitcoinUriString);
                LocalBroadcastManager.getInstance(getActivity()).sendBroadcast(action);
            }
        });

        return view;
    } catch (BitcoinURIParseException e) {
        Log.e(TAG, "Could not parse Bitcoin URI: ", e);
    }
    return null;
}