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.heske.alexandria.activities.BookDetailFragment.java

public Intent getShareIntent() {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mActivity.getString(R.string.share_subject));
    shareIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.share_text) + mBook.getTitle());
    return shareIntent;
}

From source file:de.wikilab.android.friendica01.FileUploadService.java

@Override
protected void onHandleIntent(Intent intent) {
    Log.i("Andfrnd/UploadFile", "onHandleIntent exec");

    NotificationManager mNotificationManager = (NotificationManager) getSystemService(
            Context.NOTIFICATION_SERVICE);

    //Instantiate the Notification:
    CharSequence tickerText = "Uploading...";
    Notification notification = new Notification(R.drawable.arrow_up, tickerText, System.currentTimeMillis());
    notification.flags |= Notification.FLAG_ONGOING_EVENT;

    //Define the Notification's expanded message and Intent:
    Context context = getApplicationContext();
    PendingIntent nullIntent = PendingIntent.getActivity(context, 0, new Intent(), 0);
    notification.setLatestEventInfo(context, "Upload in progress...", "You are notified here when it completes",
            nullIntent);/*from w ww  .  ja  v  a  2 s  .  c  om*/

    //Pass the Notification to the NotificationManager:
    mNotificationManager.notify(UPLOAD_PROGRESS_ID, notification);
    /*
    final TwLogin login = new TwLogin();
    login.initialize(FileUploadService.this);
    login.doLogin(FileUploadService.this, null, false);
            
    if (!login.isLoginOK()) {
       showFailMsg(FileUploadService.this, "Invalid login data or no network connection");
       return;
    }
    */
    Bundle intentPara = intent.getExtras();
    fileToUpload = (Uri) intentPara.getParcelable(Intent.EXTRA_STREAM);
    descText = intentPara.getString(EXTRA_DESCTEXT);
    subject = intentPara.getString(Intent.EXTRA_SUBJECT);

    if (targetFilename == null || targetFilename.equals(""))
        targetFilename = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss").format(new Date()) + ".txt";

    String fileSpec = Max.getRealPathFromURI(FileUploadService.this, fileToUpload);

    String tempFile = Max.IMG_CACHE_DIR + "/imgUploadTemp_" + System.currentTimeMillis() + ".jpg";
    Max.resizeImage(fileSpec, tempFile, 1024, 768);

    try {
        Log.i("Andfrnd/UploadFile", "before uploadFile");
        final TwAjax uploader = new TwAjax(FileUploadService.this, true, true);
        uploader.addPostFile(new TwAjax.PostFile("media", targetFilename, tempFile));
        uploader.addPostData("status", descText);
        uploader.addPostData("title", subject);
        uploader.addPostData("source",
                "<a href='http://friendica-for-android.wiki-lab.net'>Friendica for Android</a>");
        uploader.uploadFile(Max.getServer(this) + "/api/statuses/update", null);
        Log.i("Andfrnd/UploadFile", "after uploadFile");
        Log.i("Andfrnd/UploadFile", "isSuccess() = " + uploader.isSuccess());
        Log.i("Andfrnd/UploadFile", "getError() = " + uploader.getError());

        mNotificationManager.cancel(UPLOAD_PROGRESS_ID);
        if (uploader.isSuccess() && uploader.getError() == null) {
            JSONObject result = null;
            try {
                Log.i("Andfrnd/UploadFile", "JSON RESULT: " + uploader.getHttpCode());
                result = (JSONObject) uploader.getJsonResult();

                String postedText = result.getString("text");
                showSuccessMsg(FileUploadService.this);

            } catch (Exception e) {
                String errMes = e.getMessage() + " | " + uploader.getResult();
                if (result != null)
                    try {
                        errMes = result.getString("error");
                    } catch (JSONException fuuuuJava) {
                    }

                showFailMsg(FileUploadService.this, errMes);

                e.printStackTrace();
            }
        } else if (uploader.getError() != null) {
            showFailMsg(FileUploadService.this, uploader.getError().toString());
        } else {
            showFailMsg(FileUploadService.this, uploader.getResult());
        }

    } finally {
        new File(tempFile).delete();
    }
}

From source file:ayushi.view.fragment.SettingsFragment.java

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

    getActivity().setTitle("About App");

    mToolbar = (Toolbar) rootView.findViewById(R.id.htab_toolbar);
    if (mToolbar != null) {
        ((ECartHomeActivity) getActivity()).setSupportActionBar(mToolbar);
    }/*from   w w w .  j a  v a2s.co 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);

    submitLog = (TextView) rootView.findViewById(R.id.submit_log_txt);

    if (PreferenceHelper.getPrefernceHelperInstace().getBoolean(getActivity(), PreferenceHelper.SUBMIT_LOGS,
            true)) {

        submitLog.setText("Disable");
    } else {
        submitLog.setText("Enable");
    }

    rootView.findViewById(R.id.submit_log).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (PreferenceHelper.getPrefernceHelperInstace().getBoolean(getActivity(),
                    PreferenceHelper.SUBMIT_LOGS, true)) {
                PreferenceHelper.getPrefernceHelperInstace().setBoolean(getActivity(),
                        PreferenceHelper.SUBMIT_LOGS, false);

                submitLog.setText("Disable");
            } else {
                PreferenceHelper.getPrefernceHelperInstace().setBoolean(getActivity(),
                        PreferenceHelper.SUBMIT_LOGS, true);
                submitLog.setText("Enable");
            }

        }
    });

    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.picasso).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://github.com/square/picasso"));
            startActivity(browserIntent);

        }
    });

    rootView.findViewById(R.id.acra).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/ACRA/acra"));
            startActivity(browserIntent);

        }
    });

    rootView.findViewById(R.id.pull_zoom_view).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://github.com/Frank-Zhu/PullZoomView"));
            startActivity(browserIntent);

        }
    });

    rootView.findViewById(R.id.list_buddies).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://github.com/jpardogo/ListBuddies"));
            startActivity(browserIntent);

        }
    });

    rootView.findViewById(R.id.list_jazzy).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW,
                    Uri.parse("https://github.com/twotoasters/JazzyListView"));
            startActivity(browserIntent);

        }
    });

    rootView.findViewById(R.id.email_dev).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[] { "serveroverloadofficial@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:com.dm.material.dashboard.candybar.adapters.IntentAdapter.java

private Intent addIntentExtra(@NonNull Intent intent) {
    intent.setType("message/rfc822");
    if (mRequest.getStream().length() > 0) {
        File zip = new File(mRequest.getStream());
        Uri uri = FileHelper.getUriFromFile(mContext, mContext.getPackageName(), zip);
        if (uri == null)
            uri = Uri.fromFile(zip);//from w w w . jav a  2s.  c  om
        intent.putExtra(Intent.EXTRA_STREAM, uri);
        intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }

    intent.putExtra(Intent.EXTRA_EMAIL, new String[] { mContext.getResources().getString(R.string.dev_email) });
    intent.putExtra(Intent.EXTRA_SUBJECT, mRequest.getSubject());
    intent.putExtra(Intent.EXTRA_TEXT, mRequest.getText());
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    return intent;
}

From source file:com.secupwn.aimsicd.ui.activities.DebugLogs.java

public void sendEmail() {
    new Thread() {
        @Override/*from   w  w  w .  j a va  2  s .com*/
        public void run() {
            // Send Error Log
            try {
                String helpUs = getString(R.string.describe_the_problem_you_had);
                String log = helpUs + "\n\n" + "GETPROP:" + "\n\n" + getProp() + "\n\n" + "LOGCAT:" + "\n\n"
                        + getLogs() + "\n\n" + helpUs;

                // show a share intent
                Intent intent = new Intent(Intent.ACTION_SEND);
                intent.setType("text/html");
                // E-Mail address will ONLY be handed out when a DEVELOPER asked for the logs!
                intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "See GitHub Issues first!" });
                intent.putExtra(Intent.EXTRA_SUBJECT, "AIMSICD Error Log");
                intent.putExtra(Intent.EXTRA_TEXT, log);
                startActivity(Intent.createChooser(intent, "Send Error Log"));
            } catch (IOException e) {
                log.warn("Error reading logs", e);
            }
        }
    }.start();
}

From source file:ca.rmen.android.networkmonitor.app.log.LogActionsActivity.java

/**
 * Run the given file export, then bring up the chooser intent to share the exported file.
 *///from w w  w.  jav a2s  .  c  o  m
private void shareFile(final FileExport fileExport) {
    Log.v(TAG, "shareFile " + fileExport);
    // Use a horizontal progress bar style if we can show progress of the export.
    String dialogMessage = getString(R.string.export_progress_preparing_export);
    int dialogStyle = fileExport != null ? ProgressDialog.STYLE_HORIZONTAL : ProgressDialog.STYLE_SPINNER;
    DialogFragmentFactory.showProgressDialog(this, dialogMessage, dialogStyle, PROGRESS_DIALOG_TAG);

    AsyncTask<Void, Void, File> asyncTask = new AsyncTask<Void, Void, File>() {

        @Override
        protected File doInBackground(Void... params) {
            File file = null;
            if (fileExport != null) {
                if (!Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState()))
                    return null;
                try {
                    // Export the file in the background.
                    file = fileExport.export();
                } catch (Throwable t) {
                    Log.e(TAG, "Error exporting file " + fileExport + ": " + t.getMessage(), t);
                }
                if (file == null)
                    return null;
            }

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

            String dateRange = SummaryExport.getDataCollectionDateRange(LogActionsActivity.this);

            String messageBody = 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 += getString(R.string.export_message_text_file_attached);
            } else {
                sendIntent.setType("text/plain");
            }
            messageBody += reportSummary;
            sendIntent.putExtra(Intent.EXTRA_TEXT, messageBody);

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

        @Override
        protected void onPostExecute(File result) {
            super.onPostExecute(result);
            DialogFragment fragment = (DialogFragment) getSupportFragmentManager()
                    .findFragmentByTag(PROGRESS_DIALOG_TAG);
            if (fragment != null)
                fragment.dismissAllowingStateLoss();
            // Show a toast if we failed to export a file.
            if (fileExport != null && result == null)
                Toast.makeText(LogActionsActivity.this, R.string.export_error_sdcard_unmounted,
                        Toast.LENGTH_LONG).show();
            finish();
        }

    };
    asyncTask.execute();
}

From source file:foam.jellyfish.StarwispBuilder.java

public static void email(Context context, String emailTo, String emailCC, String subject, String emailText,
        List<String> filePaths) {
    //need to "send multiple" to get more than one attachment
    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
    emailIntent.setType("text/plain");
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { emailTo });
    emailIntent.putExtra(android.content.Intent.EXTRA_CC, new String[] { emailCC });
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);

    ArrayList<String> extra_text = new ArrayList<String>();
    extra_text.add(emailText);/*from  www.  j a  va  2  s . co  m*/
    emailIntent.putStringArrayListExtra(Intent.EXTRA_TEXT, extra_text);
    //emailIntent.putExtra(Intent.EXTRA_TEXT, emailText);

    //has to be an ArrayList
    ArrayList<Uri> uris = new ArrayList<Uri>();
    //convert from paths to Android friendly Parcelable Uri's
    for (String file : filePaths) {
        File fileIn = new File(file);
        Uri u = Uri.fromFile(fileIn);
        uris.add(u);
    }
    emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
    context.startActivity(Intent.createChooser(emailIntent, "Send mail..."));
}

From source file:com.geecko.QuickLyric.fragment.SettingsFragment.java

@Override
public boolean onPreferenceClick(Preference preference) {
    AlertDialog.Builder dialog;//from   w ww  . java2  s  .c om
    switch (preference.getKey()) {
    case "pref_about":
        dialog = new AlertDialog.Builder(getActivity());
        dialog.setView(
                getActivity().getLayoutInflater().inflate(R.layout.about_dialog, (ViewGroup) getView(), false));
        dialog.create().show();
        break;
    case "pref_contribute":
        Intent browserIntent = new Intent(Intent.ACTION_VIEW);
        browserIntent.setData(Uri.parse("https://github.com/geecko86/QuickLyric"));
        if (browserIntent.resolveActivity(getActivity().getPackageManager()) != null)
            startActivity(browserIntent);
        break;
    case "pref_beta":
        dialog = new AlertDialog.Builder(getActivity());
        dialog.setView(
                getActivity().getLayoutInflater().inflate(R.layout.beta_dialog, (ViewGroup) getView(), false));
        dialog.create().show();
        break;
    case "pref_issues":
        Intent emailIntent = new Intent(Intent.ACTION_SENDTO);
        emailIntent.setData(Uri.parse("mailto:"));
        emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "quicklyricapp@gmail.com" });
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Issues with QuickLyric");
        if (emailIntent.resolveActivity(getActivity().getPackageManager()) != null)
            startActivity(emailIntent);
        break;
    }
    return true;
}

From source file:com.hsr.hemant.ppp.MainActivity.java

@Override
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.license) {

        AlertDialog.Builder LicenseDialog = new AlertDialog.Builder(MainActivity.this);
        LicenseDialog.setTitle("Legal Notices");
        LicenseDialog.setMessage(LicenseInfo);
        LicenseDialog.show();//from ww w  . j  ava  2 s .c om

        return true;
    }
    //noinspection SimplifiableIfStatement
    //        if (id == R.id.action_settings) {
    //            return true;
    //        }
    if (id == R.id.menu_item_share) {

        Intent i = new Intent(Intent.ACTION_SEND);
        i.setType("text/plain");
        i.putExtra(Intent.EXTRA_SUBJECT, "Picoroid");
        String sAux = "\nLet me recommend you this application\n\n";
        sAux = sAux + "https://play.google.com/store/apps/details?id=com.hsr.hemant.ppp \n\n";
        i.putExtra(Intent.EXTRA_TEXT, sAux);

        setShareIntent(i);
        return true;

    }
    return super.onOptionsItemSelected(item);
}

From source file:com.reliqartz.firsttipcalc.gui.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    final Intent i;
    Log.d(TAG, "Menu item selected: " + item.getItemId());
    int itemId = item.getItemId();
    if (itemId == R.id.action_refresh) {
        i = getIntent();/*from   w ww . j  a v a 2 s.  c o  m*/
        finish();
        startActivity(i);
        overridePendingTransition(0, 0);
        return true;
    } else if (itemId == R.id.action_settings) {
        i = new Intent(this, SettingsActivity.class);
        startActivity(i);
        return true;
    } else if (itemId == R.id.action_feedback) {
        i = new Intent(android.content.Intent.ACTION_SEND);
        i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "info@reliqartz.com" });
        i.putExtra(android.content.Intent.EXTRA_SUBJECT, "Feedback: First Tip App");
        i.putExtra(android.content.Intent.EXTRA_TEXT, "Hello, ");
        i.setType("message/rfc822");
        startActivity(i);
        return true;
    } else {
        return super.onOptionsItemSelected(item);
    }
}