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.microsoft.azure.engagement.fragment.OutOfAppPushNotificationsFragment.java

/**
 * Method that displays an out-of-app notification.
 *
 * @param context           The context/*  w ww.  j a  v  a  2  s .c  o  m*/
 * @param notificationStyle The notificationStyle
 * @param actionUrl         The actionUrl
 */
private final void displayNotification(Context context, NotificationStyle notificationStyle, String actionUrl) {
    final NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
    final Resources resources = context.getResources();
    builder.setSmallIcon(R.drawable.ic_notification_default);
    builder.setLargeIcon(BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher));

    builder.setContentTitle(context.getString(R.string.out_of_app_push_notification_content_title));
    builder.setContentText(context.getString(R.string.out_of_app_push_notification_content_message));
    final Intent notificationIntent = new Intent(Intent.ACTION_VIEW);
    notificationIntent.putExtra(ReboundActivity.ACTION_URL_EXTRA,
            getString(R.string.deeplink_recent_product_updates));

    notificationIntent.setData(Uri.parse(actionUrl));
    final PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, notificationIntent,
            PendingIntent.FLAG_UPDATE_CURRENT);

    final Style style;

    switch (notificationStyle) {
    case normal:
        style = null;
        builder.setContentTitle(context.getString(R.string.out_of_app_push_notification_content_title));
        builder.setContentText(context.getString(R.string.out_of_app_push_notification_content_message));
        break;
    case bigText:
        final BigTextStyle bigTextStyle = new BigTextStyle();
        bigTextStyle.setBigContentTitle(context.getString(R.string.out_of_app_push_notification_content_title));
        bigTextStyle.setSummaryText(context.getString(R.string.out_of_app_push_notification_content_message));
        bigTextStyle.bigText(context.getString(R.string.out_of_app_push_notification_content_big_text));
        builder.setContentTitle(context.getString(R.string.out_of_app_push_notification_content_title));
        builder.setContentText(context.getString(R.string.out_of_app_push_notification_content_message));
        style = bigTextStyle;
        break;
    case bigImage:
        final BigPictureStyle bigPictureStyle = new BigPictureStyle();
        bigPictureStyle
                .setBigContentTitle(context.getString(R.string.out_of_app_push_notification_content_title));
        bigPictureStyle
                .setSummaryText(context.getString(R.string.out_of_app_push_notification_content_message));
        bigPictureStyle
                .bigPicture(BitmapFactory.decodeResource(resources, R.drawable.ic_notification_big_image));
        bigPictureStyle.bigLargeIcon(BitmapFactory.decodeResource(resources, R.mipmap.ic_launcher));
        builder.setContentTitle(context.getString(R.string.out_of_app_push_notification_content_title));
        builder.setContentText(context.getString(R.string.out_of_app_push_notification_content_message));
        style = bigPictureStyle;
        break;
    default:
        style = null;
        break;
    }

    builder.setStyle(style);
    builder.setContentIntent(pendingIntent);

    // Share action
    final Intent sharingIntent = new Intent();
    sharingIntent.setAction(Intent.ACTION_SEND);
    sharingIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.notification_share_message));
    sharingIntent.setType("text/plain");
    final PendingIntent actionShareIntent = PendingIntent.getActivity(getActivity(), 0, sharingIntent, 0);
    builder.addAction(R.drawable.ic_out_of_app_share, getString(R.string.notification_share_button_title),
            actionShareIntent);

    // Feedback action
    final Intent feedbackIntent = new Intent();
    feedbackIntent.setAction(Intent.ACTION_VIEW);
    final Uri data = Uri.parse("mailto:");
    feedbackIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.notification_feedback_email_subject));
    feedbackIntent.setData(data);
    final PendingIntent actionFeedbackIntent = PendingIntent.getActivity(getActivity(), 0, feedbackIntent, 0);
    builder.addAction(R.drawable.ic_out_of_app_send_feedback,
            getString(R.string.notification_feedback_button_title), actionFeedbackIntent);

    final Notification notification = builder.build();
    notification.flags |= Notification.FLAG_AUTO_CANCEL;

    final NotificationManager notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(OutOfAppPushNotificationsFragment.NOTIFICATION_ID++, notification);

}

From source file:fr.simon.marquis.secretcodes.ui.MainActivity.java

private void sendEmail(ArrayList<SecretCode> secretCodes) {
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("message/rfc822");
    i.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.extra_email) });
    i.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.extra_subject));
    i.putExtra(Intent.EXTRA_TEXT, generateEmailBody(secretCodes));
    i.putExtra(Intent.EXTRA_STREAM, ExportContentProvider.CONTENT_URI);
    startActivity(Intent.createChooser(i, null));
}

From source file:com.example.admin.news.mvp.ui.activities.NewsDetailActivity.java

private void share() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share));
    intent.putExtra(Intent.EXTRA_TEXT, getShareContents());
    startActivity(Intent.createChooser(intent, getTitle()));
}

From source file:name.zurell.kirk.apps.android.rhetolog.RhetologApplication.java

/** Called when a session detail view asks to send session results somewhere. 
 * Generates a link to the session report Uri, and lets the remote program read from it. 
 * The {@link RhetologContentProvider} generates the result file on demand.
 * //ww  w .  j  av  a 2 s  .c  om
 * */

@Override
public void onSessionSend(Context context, Uri session) {

    // Send to the program selected by the chooser below.
    Intent sendSession = new Intent(Intent.ACTION_SEND);

    // Permit to read from Rhetolog URIs.
    sendSession.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    // Note type of send as report.
    sendSession.setType(RhetologContract.RHETOLOG_TYPE_SESSION_REPORT);

    sendSession.putExtra(Intent.EXTRA_SUBJECT, "Sending session " + session);

    // Send text as text.
    sendSession.putExtra(Intent.EXTRA_TEXT, reportForSession(session));

    // Send text as URI to be read.
    sendSession.putExtra(Intent.EXTRA_STREAM,
            Uri.parse(RhetologContract.SESSIONSREPORT + "/" + session.getLastPathSegment()));

    // Permit user to choose target of send.
    context.startActivity(Intent.createChooser(sendSession, "Send session results"));
}

From source file:com.github.dfa.diaspora_android.activity.ShareActivity.java

void handleSendSubject(Intent intent) {
    final String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
    final String sharedSubject = intent.getStringExtra(Intent.EXTRA_SUBJECT);
    final String sharedBy = getString(R.string.shared_by_diaspora_android);
    if (sharedSubject != null) {
        webView.setWebViewClient(new WebViewClient() {

            public void onPageFinished(WebView view, String url) {

                webView.setWebViewClient(new WebViewClient() {
                    @Override/*ww  w  .j av a2 s  .  co m*/
                    public boolean shouldOverrideUrlLoading(WebView view, String url) {

                        finish();

                        Intent i = new Intent(ShareActivity.this, MainActivity.class);
                        i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                        startActivity(i);

                        return false;
                    }
                });

                webView.loadUrl("javascript:(function() { "
                        + "document.getElementsByTagName('textarea')[0].style.height='110px'; "
                        + "document.getElementsByTagName('textarea')[0].innerHTML = '**" + sharedSubject + "** "
                        + sharedText + " " + sharedBy + "'; "
                        + "    if(document.getElementById(\"main_nav\")) {"
                        + "        document.getElementById(\"main_nav\").parentNode.removeChild("
                        + "        document.getElementById(\"main_nav\"));"
                        + "    } else if (document.getElementById(\"main-nav\")) {"
                        + "        document.getElementById(\"main-nav\").parentNode.removeChild("
                        + "        document.getElementById(\"main-nav\"));" + "    }" + "})();");
            }
        });
    }
}

From source file:com.eyekabob.util.EyekabobHelper.java

public static void launchEmail(Activity activity) {
    Intent emailIntent = new Intent(Intent.ACTION_SEND);
    emailIntent.setType("plain/text");
    String to[] = { "philj21@yahoo.com", "adam.sill01@gmail.com", "coffbr01@gmail.com" };
    emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Eyekabob Advertising");
    String label = activity.getResources().getString(R.string.write_email);
    activity.startActivity(Intent.createChooser(emailIntent, label));
}

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

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    boolean ret = true;

    switch (item.getItemId()) {
    case R.id.menu_save:
        setEditorState(STATE_VIEW);/*from   w w w .  j  av a2  s. c o  m*/
        saveNoteData();
        break;
    case R.id.menu_edit:
        setEditorState(STATE_EDIT);
        break;
    case R.id.menu_append_tag:
        Bundle bundle = new Bundle();
        bundle.putString("selectedNoteUri", mNoteUri.toString());
        FragmentManager manager = getActivity().getSupportFragmentManager();
        TagDialogListFragment fragment = TagDialogListFragment.newInstance();
        fragment.setArguments(bundle);
        fragment.show(manager, Config.TAG_TAGDIALOGLIST_FRAGM);
        break;
    case R.id.menu_allnotes:
        FragmentManager manager2 = getSherlockActivity().getSupportFragmentManager();
        FragmentUtils.replaceFragment(manager2, NoteListFragment.newInstance(), null,
                Config.TAG_NOTELIST_FRAGM);
        break;
    case R.id.menu_share:
        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT, mTitleText.getText().toString());
        intent.putExtra(Intent.EXTRA_TEXT, mBodyText.getText().toString());
        startActivity(intent);
        break;
    default:
        ret = super.onOptionsItemSelected(item);
        break;
    }
    return ret;
}

From source file:com.chatwing.whitelabel.managers.ChatboxModeManager.java

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    MenuItem notificationItem = menu.findItem(R.id.manage_notification);
    if (notificationItem != null) {
        if (mCurrentChatBoxManager.getCurrentChatBox() == null
                || mCurrentChatBoxManager.getCurrentChatBox().getNotificationStatus() == null
                || mUserManager.getCurrentUser() == null) {
            notificationItem.setVisible(false);
        } else {/*w  w w .  ja  v  a  2 s.co m*/
            notificationItem.setVisible(true);
        }
    }

    MenuItem shareChatBoxItem = menu.findItem(R.id.share_chat_box);
    MenuItem copyAliasItem = menu.findItem(R.id.copy_alias);
    MenuItem manageBlackListItem = menu.findItem(R.id.manage_blacklist);
    MenuItem bookmarkChatBoxItem = menu.findItem(R.id.bookmark_chat_box);
    MenuItem onlineUsersItem = menu.findItem(R.id.online_users);

    // Invalidate all menu related objects
    onlineUsersItem.setVisible(false);
    mOnlineUsersBadgeView.hide();
    shareChatBoxItem.setVisible(false);
    copyAliasItem.setVisible(false);
    manageBlackListItem.setVisible(false);
    bookmarkChatBoxItem.setVisible(false);
    mediaAddItem.setVisible(false);

    // Now config them
    if (mCurrentChatBoxManager.getCurrentChatBox() != null) {
        // When main view or online users drawer is opened
        // and current chat box is available.
        onlineUsersItem.setVisible(true);
        shareChatBoxItem.setVisible(true && Constants.ALLOW_SHARE_CHATBOX);
        if (mNumOfOnlineUser > 0) {
            mOnlineUsersBadgeView.setText(Integer.toString(mNumOfOnlineUser));
            mOnlineUsersBadgeView.show();
        }

        // Config share intent for share chat box item
        AppCompatActivity activity = mActivityDelegate.getActivity();
        ChatBox chatBox = mCurrentChatBoxManager.getCurrentChatBox();
        String shareText = mApiManager.getChatBoxUrl(chatBox.getKey());
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.message_share_chat_box_subject));
        intent.putExtra(Intent.EXTRA_TEXT, shareText);
        ShareActionProvider shareChatBoxActionProvider = (ShareActionProvider) MenuItemCompat
                .getActionProvider(shareChatBoxItem);
        shareChatBoxActionProvider.setShareIntent(intent);

        if (mBuildManager.isOfficialChatWingApp() && mUserManager.userCanBookmark() && !ChatWingContentProvider
                .hasSyncedBookmarkInDB(activity.getContentResolver(), chatBox.getId())) {
            bookmarkChatBoxItem.setVisible(true);
        }

        if (mBuildManager.isSupportedMusicBox()) {
            mediaAddItem.setVisible(true);
        }

        if (chatBox.getAlias() != null && Constants.ALLOW_SHARE_CHATBOX) {
            copyAliasItem.setVisible(true);
        }
        if (mUserManager.userHasPermission(chatBox, PermissionsValidator.Permission.UNBLOCK_USER)) {
            manageBlackListItem.setVisible(true);
        }

        updateControlUI(chatBox);
    }

    return true;
}

From source file:aerizostudios.com.cropshop.MainActivity.java

@Override
public void onMenuItemClick(View clickedView, int position) {

    if (position == 1) {

        AlertDialog.Builder alert = new AlertDialog.Builder(this);

        LayoutInflater inflater = (LayoutInflater) getApplicationContext()
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = inflater.inflate(R.layout.photo_quality, null);
        alert.setView(v);//from ww w .  j a  va  2s  .c  om

        alert.setTitle("Select Photo Quality");
        alert.setPositiveButton("OKAY", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

                if (normal.isChecked()) {
                    prefs = getSharedPreferences(prefName, MODE_PRIVATE);
                    SharedPreferences.Editor editor = prefs.edit();
                    editor.putInt("res", 300);
                    editor.commit();

                } else {
                    prefs = getSharedPreferences(prefName, MODE_PRIVATE);
                    SharedPreferences.Editor editor = prefs.edit();
                    editor.putInt("res", 400);
                    editor.commit();
                }

                prefs = getSharedPreferences(prefName, MODE_PRIVATE);
                quality = prefs.getInt("res", 0);

            }

        });
        alert.setNegativeButton("CANCEL", null);

        AlertD = alert.create();

        AlertD.show();
        normal = (RadioButton) AlertD.findViewById(R.id.normalQuality);
        high = (RadioButton) AlertD.findViewById(R.id.highQuality);

        Log.d("alert pref", "alert pref" + quality);

        if (quality == 300)
            normal.setChecked(true);
        else
            high.setChecked(true);
    }

    if (position == 2) {
        Uri uri = Uri.parse("market://details?id=" + getPackageName());
        Intent myAppLinkToMarket = new Intent(Intent.ACTION_VIEW, uri);
        try {
            startActivity(myAppLinkToMarket);
        } catch (ActivityNotFoundException e) {
            Toast.makeText(this, " unable to find market app", Toast.LENGTH_LONG).show();
        }
    }

    if (position == 3) {
        try {
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_SUBJECT, "CROP SHOP");
            String sAux = "\nHey friends, Check out this COOL APP - CropShop - No Crop for Whatsapp and"
                    + " Instagram. This app helps you post images on Whatsapp and Instagram without any need "
                    + "of cropping them. It also adds Blur Effect to the Photos like Iphone and also"
                    + " Instagram filters." + "This app allows you to share the photos"
                    + " directly to Instagram,Facebook and Whatsapp from the App.\n"
                    + "Download this app from the play store.\n";
            sAux = sAux + "https://play.google.com/store/apps/details?id=aerizostudios.com.cropshop \n\n";
            i.putExtra(Intent.EXTRA_TEXT, sAux);
            startActivity(Intent.createChooser(i, "choose one"));
        } catch (Exception e) { //e.toString();
        }
    }

    if (position == 4) {
        startActivity(new Intent(this, Feedback.class));
    }
}

From source file:com.renard.ocr.documents.viewing.single.DocumentActivity.java

void shareText() {
    String shareBody = getPlainDocumentText();
    if (shareBody == null) {
        Toast.makeText(DocumentActivity.this, R.string.empty_document, Toast.LENGTH_LONG).show();
        return;/*from   w  w w.j  a  va2s  .  c o  m*/
    }

    Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
    sharingIntent.setType("text/plain");
    sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, R.string.share_subject);
    sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
    startActivity(Intent.createChooser(sharingIntent, getResources().getString(R.string.share_chooser_title)));
}