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.cerema.cloud2.ui.activity.LogHistoryActivity.java

/**
 * Start activity for sending email with logs attached
 *///from w w  w.j  av a2 s. c om
private void sendMail() {

    // For the moment we need to consider the possibility that setup.xml
    // does not include the "mail_logger" entry. This block prevents that
    // compilation fails in this case.
    String emailAddress;
    try {
        Class<?> stringClass = R.string.class;
        Field mailLoggerField = stringClass.getField("mail_logger");
        int emailAddressId = (Integer) mailLoggerField.get(null);
        emailAddress = getString(emailAddressId);
    } catch (Exception e) {
        emailAddress = "";
    }

    ArrayList<Uri> uris = new ArrayList<Uri>();

    // Convert from paths to Android friendly Parcelable Uri's
    for (String file : Log_OC.getLogFileNames()) {
        File logFile = new File(mLogPath, file);
        if (logFile.exists()) {
            uris.add(Uri.fromFile(logFile));
        }
    }

    Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);

    intent.putExtra(Intent.EXTRA_EMAIL, emailAddress);
    String subject = String.format(getString(R.string.log_send_mail_subject), getString(R.string.app_name));
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setType(MAIL_ATTACHMENT_TYPE);
    intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    try {
        startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Toast.makeText(this, getString(R.string.log_send_no_mail_app), Toast.LENGTH_LONG).show();
        Log_OC.i(TAG, "Could not find app for sending log history.");
    }

}

From source file:com.gh4a.FileViewerActivity.java

@Override
public boolean setMenuOptionItemSelected(MenuItem item) {
    String blobUrl = "https://github.com/" + mRepoOwner + "/" + mRepoName + "/blob/" + mRef + "/" + mPath;
    switch (item.getItemId()) {
    case android.R.id.home:
        getApplicationContext().openRepositoryInfoActivity(this, mRepoOwner, mRepoName,
                Intent.FLAG_ACTIVITY_CLEAR_TOP);
        return true;
    case R.id.browser:
        Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(blobUrl));
        startActivity(browserIntent);//from   w  w  w . j a  va  2  s  . c o  m
        return true;
    case R.id.share:
        Intent shareIntent = new Intent(Intent.ACTION_SEND);
        shareIntent.setType("text/plain");
        shareIntent.putExtra(Intent.EXTRA_SUBJECT, mName + " at " + mRepoOwner + "/" + mRepoName);
        shareIntent.putExtra(Intent.EXTRA_TEXT, mName + " at " + mRepoOwner + "/" + mRepoName + " " + blobUrl);
        shareIntent = Intent.createChooser(shareIntent, "Share");
        startActivity(shareIntent);
        return true;
    case 10:
        Intent intent = new Intent().setClass(FileViewerActivity.this, CommitHistoryActivity.class);
        intent.putExtra(Constants.Repository.REPO_OWNER, mRepoOwner);
        intent.putExtra(Constants.Repository.REPO_NAME, mRepoName);
        intent.putExtra(Constants.Object.PATH, mPath);
        intent.putExtra(Constants.Object.REF, mRef);
        intent.putExtra(Constants.Object.OBJECT_SHA, mSha);
        startActivity(intent);
    default:
        return true;
    }
}

From source file:com.jbirdvegas.mgerrit.cards.PatchSetPropertiesCard.java

private void setClicksToActionViews(Cursor cursor, ImageView share, ImageView browser) {

    String webAddress = getWebAddress(cursor.getString(changenum_index));

    share.setTag(R.id.webAddress, webAddress);
    share.setTag(R.id.changeID, cursor.getString(changeid_index));
    browser.setTag(R.id.webAddress, webAddress);

    share.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w  w  w .  ja v  a 2 s .  c o m*/
        public void onClick(View view) {
            String changeId = (String) view.getTag(R.id.changeID);
            String webAddress = (String) view.getTag(R.id.webAddress);

            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,
                    String.format(view.getContext().getString(R.string.commit_shared_from_mgerrit), changeId));
            intent.putExtra(Intent.EXTRA_TEXT, webAddress + " #mGerrit");
            view.getContext().startActivity(intent);
        }
    });
    browser.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String webAddress = (String) view.getTag(R.id.webAddress);

            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(webAddress));
            view.getContext().startActivity(browserIntent);
        }
    });
}

From source file:com.ckchan.assignment1.ckchan_todolist.MainActivity.java

@Override
//Selecting action bar items
public boolean onOptionsItemSelected(MenuItem item) {

    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    if (id == R.id.action_settings) {
        Settings();//from w  ww  . j av a 2  s.c o m
        return true;
    }

    //Handle presses on the action bar items
    switch (item.getItemId()) {

    case R.id.summary_info:

        SummaryInfo();
        return true;

    case R.id.email_all:

        try {

            Context context = getApplicationContext();
            TaskDatabase taskDatabase = new TaskDatabase();
            ;
            Email email = taskDatabase.loadEmailAddress(context);

            ArrayList<TodoTask> taskArray = (ArrayList<TodoTask>) taskDatabase.loadTaskData(context);
            ArrayList<TodoTask> archiveArray = (ArrayList<TodoTask>) taskDatabase.loadArchiveData(context);

            //StringBuilder code from:
            //http://stackoverflow.com/questions/12899953/in-java-how-to-append-a-string-more-efficiently
            StringBuilder stringBuilder = new StringBuilder();

            if (email != null) {

                Intent i = new Intent(Intent.ACTION_SEND);
                i.setType("message/rfc822");
                i.putExtra(Intent.EXTRA_EMAIL, new String[] { email.getAddress() });
                i.putExtra(Intent.EXTRA_SUBJECT, "Todo and Archive Tasks");

                stringBuilder.append("Todo Tasks\n");

                for (TodoTask task : taskArray) {

                    stringBuilder.append(task.getTaskDescription() + "\n");
                }
                stringBuilder.append("Archive Tasks\n");

                for (TodoTask task : archiveArray) {

                    stringBuilder.append(task.getTaskDescription() + "\n");
                }
                String emailContent = stringBuilder.toString();
                i.putExtra(Intent.EXTRA_TEXT, emailContent);

                try {

                    startActivity(Intent.createChooser(i, "Send mail..."));
                } catch (android.content.ActivityNotFoundException ex) {

                    Toast.makeText(context, "There are no email clients installed.", Toast.LENGTH_SHORT).show();
                }
            }

        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.dm.material.dashboard.candybar.fragments.dialog.AboutFragment.java

@Override
public void onClick(View view) {
    int id = view.getId();
    Intent intent = null;/* w ww  .ja v a  2s  .c om*/
    if (id == R.id.email) {
        try {
            final Intent email = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",
                    getActivity().getResources().getString(R.string.about_email), null));
            email.putExtra(Intent.EXTRA_SUBJECT, (getActivity().getResources().getString(R.string.app_name)));
            getActivity().startActivity(
                    Intent.createChooser(email, getActivity().getResources().getString(R.string.email_client)));
            dismiss();
        } catch (ActivityNotFoundException e) {
            Log.d(Tag.LOG_TAG, Log.getStackTraceString(e));
        }
        return;
    } else if (id == R.id.link1) {
        intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(getActivity().getResources().getString(R.string.about_link_1_url)));
    } else if (id == R.id.link2) {
        intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(getActivity().getResources().getString(R.string.about_link_2_url)));
    } else if (id == R.id.dev_link1) {
        intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse(getActivity().getResources().getString(R.string.about_dashboard_dev_github_url)));
    } else if (id == R.id.dev_link2) {
        intent = new Intent(Intent.ACTION_VIEW, Uri
                .parse(getActivity().getResources().getString(R.string.about_dashboard_dev_google_plus_url)));
    }

    try {
        getActivity().startActivity(intent);
    } catch (ActivityNotFoundException e) {
        Log.d(Tag.LOG_TAG, Log.getStackTraceString(e));
    }
}

From source file:com.abiansoftware.lib.reader.AbianReaderItemActivity.java

@Override
public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        Intent intent = new Intent(this, AbianReaderActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);/*from  ww w  .j  av a 2s . c  om*/

        return true;
    } else if (item.getItemId() == SHARE_ITEM_ID) {
        String shareMessage = getString(R.string.share_message);
        String shareTitle = getString(R.string.share_title);

        AbianReaderItem targetItem = AbianReaderApplication.getData().getItemNumber(m_currentPage);

        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
        sharingIntent.setType("text/plain");
        sharingIntent.putExtra(Intent.EXTRA_SUBJECT, shareMessage);
        sharingIntent.putExtra(Intent.EXTRA_TEXT, targetItem.getLink());
        startActivity(Intent.createChooser(sharingIntent, shareTitle));

        return true;
    } else if (item.getItemId() == OPEN_BROWSER_ITEM_ID) {
        AbianReaderItem targetItem = AbianReaderApplication.getData().getItemNumber(m_currentPage);

        String url = targetItem.getLink();
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        startActivity(i);
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.zxing.qrcode.decoding.CaptureActivityHandler.java

@Override
public void handleMessage(Message message) {
    switch (message.what) {
    case R.id.auto_focus:
        // Log.d(TAG, "Got auto-focus message");
        // When one auto focus pass finishes, start another. This is the
        // closest thing to
        // continuous AF. It does seem to hunt a bit, but I'm not sure what
        // else to do.
        if (state == State.PREVIEW) {
            CameraManager.get().requestAutoFocus(this, R.id.auto_focus);
        }/*from  ww  w  .  j a  v  a 2 s  . c om*/
        break;
    case R.id.restart_preview:
        Log.d(TAG, "Got restart preview message");
        restartPreviewAndDecode();
        break;
    case R.id.decode_succeeded:
        Log.d(TAG, "Got decode succeeded message");
        state = State.SUCCESS;
        Bundle bundle = message.getData();
        Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);
        final String str_result = ((Result) message.obj).getText();
        System.out.println("====str_result====" + str_result);
        String match = "^[0-9]{13}";
        boolean b = str_result.matches(match);
        // Toast.makeText(activity, ""+b, 1).show();
        // activity.handleDecode((Result) message.obj, barcode);
        if (b) {
            String url = RequestUrls.TIAOXING_CODE_URL.replace("[code]", str_result);
            FinalHttp fh = new FinalHttp();
            fh.get(url, new AjaxCallBack<Object>() {
                @Override
                public void onSuccess(Object t) {
                    // TODO Auto-generated method stub
                    super.onSuccess(t);
                    try {

                        System.out.println("===TIAOXING_CODE_URL====" + new JSONObject(t.toString()));
                        Intent tagIntent = new Intent(activity, TagdetialActivity.class);
                        tagIntent.putExtra("jsonStr", t.toString());
                        tagIntent.putExtra("barcodes", str_result);
                        tagIntent.putExtra("eid", eid);
                        tagIntent.putExtra("tag_ids", tag_ids);
                        activity.startActivity(tagIntent);
                    } catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }

                @Override
                public void onFailure(Throwable t, String strMsg) {
                    // TODO Auto-generated method stub
                    super.onFailure(t, strMsg);
                }
            });
        } else {
            try {
                Intent intent = new Intent(Intent.ACTION_VIEW);
                // //// intent.setPackage("com.tencent.mm");//
                intent.putExtra(Intent.EXTRA_SUBJECT, "share");
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                // // 
                // intent.setData(Uri.parse("http://weixin.qq.com/r/o3w_sRvEMSVOhwrSnyCH"));
                intent.setData(Uri.parse(str_result));
                activity.startActivity(intent);
            } catch (Exception e) {
                Toast.makeText(activity, R.string.no_wechat_rem, Toast.LENGTH_SHORT).show();
            }
        }

        break;
    case R.id.decode_failed:
        // We're decoding as fast as possible, so when one decode fails,
        // start another.
        state = State.PREVIEW;
        CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode);
        break;
    case R.id.return_scan_result:
        Log.d(TAG, "Got return scan result message");
        activity.setResult(Activity.RESULT_OK, (Intent) message.obj);
        activity.finish();
        break;
    }
}

From source file:com.fsa.en.dron.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    RateThisApp.Config config = new RateThisApp.Config(5, 10);
    config.setTitle(R.string.my_own_title);
    config.setMessage(R.string.my_own_message);
    config.setYesButtonText(R.string.my_own_rate);
    config.setNoButtonText(R.string.my_own_thanks);
    config.setCancelButtonText(R.string.my_own_cancel);
    RateThisApp.init(config);//from   www.  j a v  a  2  s  .  c o  m
    RateThisApp.setCallback(new RateThisApp.Callback() {
        @Override
        public void onYesClicked() {
            final String appPackageName = getPackageName(); // getPackageName() from Context or Activity  object
            try {
                startActivity(
                        new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=" + appPackageName)));
            } catch (android.content.ActivityNotFoundException anfe) {
                startActivity(new Intent(Intent.ACTION_VIEW,
                        Uri.parse("http://play.google.com/store/apps/details?id=" + appPackageName)));
            }
        }

        @Override
        public void onNoClicked() {
            TastyToast.makeText(getApplicationContext(), "Vuelve pronto!", TastyToast.LENGTH_LONG,
                    TastyToast.INFO);
        }

        @Override
        public void onCancelClicked() {
            TastyToast.makeText(getApplicationContext(), "Prometo tomar mejores fotografias!",
                    TastyToast.LENGTH_LONG, TastyToast.ERROR);
        }
    });
    button = (Button) findViewById(R.id.button);
    button.setVisibility(View.INVISIBLE);
    button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            checkConnection();
        }
    });
    BottomNavigationBar bottomNavigationBar = (BottomNavigationBar) findViewById(R.id.bottom_navigation_bar);
    bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_RIPPLE);
    bottomNavigationBar.setMode(BottomNavigationBar.MODE_FIXED);
    bottomNavigationBar.setBackgroundStyle(BottomNavigationBar.BACKGROUND_STYLE_STATIC);
    bottomNavigationBar.setBarBackgroundColor(R.color.material_light_blue_800);
    bottomNavigationBar.setActiveColor(R.color.material_grey_900);
    bottomNavigationBar.setInActiveColor(R.color.material_blue_grey_200);
    bottomNavigationBar.addItem(new BottomNavigationItem(R.drawable.compose, "Mensaje"))
            .addItem(new BottomNavigationItem(R.drawable.sociales, "Sociales"))
            .addItem(new BottomNavigationItem(R.drawable.share, "Cuntale a un amigo")).initialise();
    bottomNavigationBar.setTabSelectedListener(new BottomNavigationBar.OnTabSelectedListener() {
        @Override
        public void onTabSelected(int position) {
            switch (position) {
            case 0:
                Intent email = new Intent(Intent.ACTION_SEND);
                email.putExtra(Intent.EXTRA_EMAIL, new String[] { "marceloespinoza00@gmail.com" });
                email.putExtra(Intent.EXTRA_SUBJECT, "Formosa en dron");
                email.putExtra(Intent.EXTRA_TEXT, "Dej tu mensaje");
                email.setType("message/rfc822");
                startActivity(Intent.createChooser(email, "Elige un cliente :"));
                break;
            case 1:
                Intent intent = new Intent(getApplication(), FacebookActivity.class);
                startActivity(intent);
                break;
            case 2:

                Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
                sharingIntent.setType("text/plain");
                sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Formosa en dron");
                sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT,
                        "https://play.google.com/store/apps/details?id=com.fsa.en.dron");
                startActivity(Intent.createChooser(sharingIntent, "Compartir via"));
                break;

            }

        }

        @Override
        public void onTabUnselected(int position) {

        }

        @Override
        public void onTabReselected(int position) {
            switch (position) {
            case 0:

                break;
            case 1:
                Intent intent = new Intent(getApplication(), FacebookActivity.class);
                startActivity(intent);
                break;
            case 2:

                break;

            }
        }
    });
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    LayoutInflater inflator = LayoutInflater.from(this);
    View v = inflator.inflate(R.layout.toolbar_title, null);
    Typeface budget = Typeface.createFromAsset(getAssets(), "fonts/Budget.otf");
    Typeface typographica = Typeface.createFromAsset(getAssets(), "fonts/TypoGraphica.otf");
    TextView mToolbarCustomTitle = (TextView) v.findViewById(R.id.title);
    TextView mToolbarCustomSubTitle = (TextView) v.findViewById(R.id.subtitle);
    mToolbarCustomTitle.setText("Formosa");
    mToolbarCustomSubTitle.setText("en dron");
    mToolbarCustomTitle.setTypeface(typographica);
    mToolbarCustomSubTitle.setTypeface(budget);
    getSupportActionBar().setCustomView(v);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    toolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
        @Override
        public boolean onMenuItemClick(MenuItem item) {
            int id = item.getItemId();
            if (id == R.id.recargar) {
                checkConnection();
            }
            if (id == R.id.info) {
                showDialog();
            }
            return false;
        }
    });
    recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
    recyclerView.addOnItemTouchListener(new GalleryAdapter.RecyclerTouchListener(getApplicationContext(),
            recyclerView, new GalleryAdapter.ClickListener() {
                @Override
                public void onClick(View view, int position) {
                    Bundle bundle = new Bundle();
                    bundle.putSerializable("images", images);
                    bundle.putInt("position", position);

                    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                    SlideshowDialogFragment newFragment = SlideshowDialogFragment.newInstance();
                    newFragment.setArguments(bundle);
                    newFragment.show(ft, "slideshow");
                }

                @Override
                public void onLongClick(View view, int position) {

                }
            }));
    pDialog = new ProgressDialog(this);
    images = new ArrayList<>();
    mAdapter = new GalleryAdapter(getApplicationContext(), images);
    RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(getApplicationContext(), 2);
    recyclerView.setLayoutManager(mLayoutManager);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(mAdapter);

}

From source file:co.nerdart.ourss.fragment.EntriesListFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_share_starred: {
        String starredList = "";
        Cursor cursor = mEntriesCursorAdapter.getCursor();
        if (cursor != null && !cursor.isClosed()) {
            int titlePos = cursor.getColumnIndex(EntryColumns.TITLE);
            int linkPos = cursor.getColumnIndex(EntryColumns.LINK);
            if (cursor.moveToFirst()) {
                do {
                    starredList += cursor.getString(titlePos) + "\n" + cursor.getString(linkPos) + "\n\n";
                } while (cursor.moveToNext());
            }/*from www.  j a va2 s.co  m*/
            startActivity(Intent.createChooser(
                    new Intent(Intent.ACTION_SEND)
                            .putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_favorites_title))
                            .putExtra(Intent.EXTRA_TEXT, starredList).setType(Constants.MIMETYPE_TEXT_PLAIN),
                    getString(R.string.menu_share)));
        }
        return true;
    }
    case R.id.menu_refresh: {
        if (!FetcherService.isRefreshingFeeds) {
            getActivity().startService(
                    new Intent(getActivity(), FetcherService.class).setAction(Constants.ACTION_REFRESH_FEEDS));
        }
        return true;
    }
    case R.id.menu_all_read: {
        mEntriesCursorAdapter.markAllAsRead();
        return true;
    }
    case R.id.menu_hide_read: {
        if (!PrefUtils.getBoolean(PrefUtils.SHOW_READ, true)) {
            PrefUtils.putBoolean(PrefUtils.SHOW_READ, true);
            item.setTitle(R.string.context_menu_hide_read).setIcon(R.drawable.hide_reads);
        } else {
            PrefUtils.putBoolean(PrefUtils.SHOW_READ, false);
            item.setTitle(R.string.context_menu_show_read).setIcon(R.drawable.view_reads);
        }
        return true;
    }
    case R.id.menu_settings: {
        startActivity(new Intent(getActivity(), GeneralPrefsActivity.class));
        return true;
    }
    }
    return super.onOptionsItemSelected(item);
}

From source file:com.enadein.carlogbook.ui.AboutFragment.java

private Intent getTextShareIntent() {
    Intent intent = new Intent(Intent.ACTION_SEND);

    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.share_title));
    intent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_text));

    return intent;
}