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.android.messaging.datamodel.NoConfirmationSmsSendService.java

@Override
protected void onHandleIntent(final Intent intent) {
    if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
        LogUtil.v(TAG, "NoConfirmationSmsSendService onHandleIntent");
    }/*from   w  w  w .j  a  va 2  s . c o  m*/

    final String action = intent.getAction();
    if (!TelephonyManager.ACTION_RESPOND_VIA_MESSAGE.equals(action)) {
        if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
            LogUtil.v(TAG, "NoConfirmationSmsSendService onHandleIntent wrong action: " + action);
        }
        return;
    }
    final Bundle extras = intent.getExtras();
    if (extras == null) {
        if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
            LogUtil.v(TAG, "Called to send SMS but no extras");
        }
        return;
    }

    // Get all possible extras from intent
    final String conversationId = intent.getStringExtra(UIIntents.UI_INTENT_EXTRA_CONVERSATION_ID);
    final String selfId = intent.getStringExtra(EXTRA_SELF_ID);
    final boolean requiresMms = intent.getBooleanExtra(UIIntents.UI_INTENT_EXTRA_REQUIRES_MMS, false);
    final String message = getText(intent, Intent.EXTRA_TEXT);
    final String subject = getText(intent, Intent.EXTRA_SUBJECT);
    final int subId = extras.getInt(EXTRA_SUBSCRIPTION, ParticipantData.DEFAULT_SELF_SUB_ID);

    final Uri intentUri = intent.getData();
    final String recipients = intentUri != null ? MmsUtils.getSmsRecipients(intentUri) : null;

    if (TextUtils.isEmpty(recipients) && TextUtils.isEmpty(conversationId)) {
        if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
            LogUtil.v(TAG, "Both conversationId and recipient(s) cannot be empty");
        }
        return;
    }

    if (extras.getBoolean("showUI", false)) {
        startActivity(new Intent(this, ConversationListActivity.class));
    } else {
        if (TextUtils.isEmpty(message)) {
            if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
                LogUtil.v(TAG, "Message cannot be empty");
            }
            return;
        }

        // TODO: it's possible that a long message would require sending it via mms,
        // but we're not testing for that here and we're sending the message as an sms.

        if (TextUtils.isEmpty(conversationId)) {
            InsertNewMessageAction.insertNewMessage(subId, recipients, message, subject);
        } else {
            MessageData messageData = null;
            if (requiresMms) {
                if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
                    LogUtil.v(TAG, "Auto-sending MMS message in conversation: " + conversationId);
                }
                messageData = MessageData.createDraftMmsMessage(conversationId, selfId, message, subject);
            } else {
                if (LogUtil.isLoggable(TAG, LogUtil.VERBOSE)) {
                    LogUtil.v(TAG, "Auto-sending SMS message in conversation: " + conversationId);
                }
                messageData = MessageData.createDraftSmsMessage(conversationId, selfId, message);
            }
            InsertNewMessageAction.insertNewMessage(messageData);
        }
        UpdateMessageNotificationAction.updateMessageNotification();
    }
}

From source file:com.gh4a.activities.CommitActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    String diffUrl = "https://github.com/" + mRepoOwner + "/" + mRepoName + "/commit/" + mObjectSha;
    switch (item.getItemId()) {
    case R.id.browser:
        IntentUtils.launchBrowser(this, Uri.parse(diffUrl));
        return true;
    case R.id.share:
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_commit_subject,
                mObjectSha.substring(0, 7), mRepoOwner + "/" + mRepoName));
        shareIntent.putExtra(Intent.EXTRA_TEXT, diffUrl);
        shareIntent = Intent.createChooser(shareIntent, getString(R.string.share_title));
        startActivity(shareIntent);//from  ww  w . j  a v  a2  s  . c o m
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:codepath.watsiapp.fragments.DonateShareFragment.java

private void startShareIntent() {
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.putExtra(Intent.EXTRA_TEXT, patientProfileUrl);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Fund Treatment");
    startActivity(Intent.createChooser(shareIntent, "Share Story"));
}

From source file:com.jwork.dhammapada.controller.DhammapadaController.java

private void shareVerse(Verse verse) {
    Intent intentText = new Intent(Intent.ACTION_SEND);
    intentText.setType("text/plain");
    intentText.putExtra(Intent.EXTRA_SUBJECT, verse.getChapter().getTitlePali() + " - " + verse.getIndex());
    intentText.putExtra(Intent.EXTRA_TEXT,
            verse.getContentPali() + "\n\n" + verse.getContentEng() + "\n\n" + verse.getContentId());
    try {/*from w  w w.jav a 2 s.  c  o  m*/
        activity.startActivity(Intent.createChooser(intentText, "Select your favorite Social Media network"));
    } catch (ActivityNotFoundException e) {
        Toast.makeText(activity, "Failed to share this application", Toast.LENGTH_LONG).show();
    }
}

From source file:id.zelory.tanipedia.activity.BacaActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_baca);

    tmp = getIntent().getParcelableExtra("berita");

    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);// www .  java 2  s . c o m
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    collapsingToolbar.setTitle("TaniPedia");

    animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow);
    gambar = (ImageView) findViewById(R.id.gambar);
    judul = (TextView) findViewById(R.id.judul);
    tanggal = (TextView) findViewById(R.id.tanggal);
    isi = (DocumentView) findViewById(R.id.isi);
    root = (LinearLayout) findViewById(R.id.ll_root_berita);

    fabButton = (FabButton) findViewById(R.id.determinate);
    fabButton.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_SUBJECT, berita.getJudul());
            intent.putExtra(Intent.EXTRA_TEXT, berita.getJudul() + "\n" + berita.getAlamat());
            startActivity(Intent.createChooser(intent, "Bagikan"));
        }
    });

    generateBeritaLainnya();

    new DownloadData().execute();
}

From source file:com.qasp.diego.arsp.homeFrag.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    RadioGroup rgroup_avaliacao;//from  ww  w.ja  v a 2  s .  c  o m
    Button button_enviar;

    final View rootview = inflater.inflate(R.layout.fragment_home, container, false);
    rgroup_avaliacao = (RadioGroup) rootview.findViewById(R.id.radio_avaliacao);
    rgroup_avaliacao.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            switch (checkedId) {
            case R.id.radiobom:
                avaliacao_escolhida = "Bom";
                break;
            case R.id.radiook:
                avaliacao_escolhida = "OK";
                break;
            case R.id.radioruim:
                avaliacao_escolhida = "Ruim";
                break;
            }
            Log.d("avaliacao_escolhida", avaliacao_escolhida);
        }
    });

    button_enviar = (Button) rootview.findViewById(R.id.benviar);
    button_enviar.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            // Usuario nao escolheu uma avaliacao. Mostrar Dialogo de Erro.
            if (avaliacao_escolhida == null) {
                AlertDialog.Builder erro = new AlertDialog.Builder(v.getContext());
                erro.setMessage("Voc deve selecionar uma Avaliao.");
                erro.setCancelable(true);
                erro.setNeutralButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
                AlertDialog alerta = erro.create();
                alerta.show();
            } else {
                Intent i = new Intent(Intent.ACTION_SEND);
                i.setType("message/rfc822");
                i.putExtra(Intent.EXTRA_EMAIL, new String[] { "iqspsuporte@gmail.com" });
                i.putExtra(Intent.EXTRA_SUBJECT, "ArSP - Feedback" + " (" + avaliacao_escolhida + ")");
                EditText et = (EditText) rootview.findViewById(R.id.editText);
                i.putExtra(Intent.EXTRA_TEXT, "AVALIAO:" + avaliacao_escolhida + "\n" + "MOTIVO:" + "\n"
                        + et.getText().toString());
                try {
                    startActivity(Intent.createChooser(i, "Send mail..."));
                } catch (android.content.ActivityNotFoundException ex) {
                    Log.d("Deu", "RUim");
                }
            }
        }
    });

    return rootview;
}

From source file:com.ideateam.plugin.Emailer.java

private void SendEmail(String email, String subject, String text, String attachFile) {

    String attachPath = Environment.getExternalStorageDirectory().getAbsolutePath() + "/UAR2015/" + attachFile;
    File file = new File(attachPath);

    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { email });
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
    intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(text));

    this.cordova.getActivity().startActivity(Intent.createChooser(intent, "Send email..."));

}

From source file:com.activiti.android.app.fragments.task.TaskFormFragment.java

@Subscribe
public void onDownloadTransferEvent(DownloadTransferEvent event) {
    if (event.hasException) {
        Snackbar.make(getActivity().findViewById(R.id.left_panel), event.exception.getMessage(),
                Snackbar.LENGTH_SHORT).show();
        return;/* ww  w.  ja va  2 s. c  o  m*/
    }

    hideWaiting();

    try {
        switch (event.mode) {
        case ContentTransferSyncAdapter.MODE_SHARE:
            Intent sendIntent = new Intent(Intent.ACTION_SEND);
            sendIntent.putExtra(Intent.EXTRA_SUBJECT, event.data.getName());
            sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(event.data));
            sendIntent.setType(event.mimetype);
            getActivity().startActivity(
                    Intent.createChooser(sendIntent, getResources().getText(R.string.action_send_file)));
            break;
        case ContentTransferSyncAdapter.MODE_OPEN_IN:
            Intent viewIntent = new Intent(Intent.ACTION_VIEW);
            viewIntent.putExtra(Intent.EXTRA_SUBJECT, event.data.getName());
            viewIntent.setDataAndType(Uri.fromFile(event.data), event.mimetype);
            startActivity(viewIntent);
            break;
        }
    } catch (ActivityNotFoundException e) {
        Snackbar.make(getActivity().findViewById(R.id.left_panel), R.string.file_editor_error_open,
                Snackbar.LENGTH_SHORT).show();
    }
}

From source file:com.jaspervanriet.huntingthatproduct.Activities.CollectionActivity.java

private Intent getShareIntent() {
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("text/plain");
    i.putExtra(Intent.EXTRA_SUBJECT, mCollection.title);
    i.putExtra(Intent.EXTRA_TEXT, mCollection.collectionUrl);
    return i;//w  w w  .j  a  va 2  s .c  o  m
}

From source file:com.honu.giftwise.InfoActivity.java

protected void sendEmail() {
    final Intent intent = new Intent(android.content.Intent.ACTION_SEND);
    intent.setType("message/rfc822");
    intent.putExtra(android.content.Intent.EXTRA_EMAIL,
            new String[] { getString(R.string.mail_feedback_email) });
    intent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.mail_feedback_subject));
    intent.putExtra(android.content.Intent.EXTRA_TEXT, getString(R.string.mail_feedback_message));

    try {//from  w  w w . j  a  v a  2 s  . c  o  m
        startActivity(Intent.createChooser(intent, getString(R.string.title_send_feedback)));
        finish();
    } catch (android.content.ActivityNotFoundException ex) {
        Toast.makeText(InfoActivity.this, "There is no email client installed.", Toast.LENGTH_SHORT).show();
    }
}