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.phonegap.cordova.FileOpener.java

private void openFile(String url, String type) throws IOException {
    // Create URI
    Uri uri = Uri.parse(url);//from w  ww .  j  ava2 s. co  m

    Intent intent = null;
    Log.v("FileOpener", "Type: " + type);

    if (type.equals("pdfshare")) {
        intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
        // intent.setDataAndType(uri, "application/pdf");
        intent.setType("application/pdf");
        intent.putExtra(Intent.EXTRA_SUBJECT, "AMR Report");
        intent.putExtra(Intent.EXTRA_TEXT, "");
        intent.putExtra(Intent.EXTRA_STREAM, uri);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    } else if (url.contains(".pdf")) {
        // PDF file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "application/pdf");
    } else if (url.contains(".ppt") || url.contains(".pptx")) {
        // Powerpoint file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "application/vnd.ms-powerpoint");
    } else if (url.contains(".xls") || url.contains(".xlsx")) {
        // Excel file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "application/vnd.ms-excel");
    } else if (url.contains(".rtf")) {
        // RTF file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "application/rtf");
    } else if (url.contains(".wav")) {
        // WAV audio file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "audio/x-wav");
    } else if (url.contains(".gif")) {
        // GIF file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "image/gif");
    } else if (url.contains(".jpg") || url.contains(".jpeg")) {
        // JPG file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "image/jpeg");
    } else if (url.contains(".png")) {
        // PNG file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "image/png");
    } else if (url.contains(".txt")) {
        // Text file
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "text/plain");
    } else if (url.contains(".mpg") || url.contains(".mpeg") || url.contains(".mpe") || url.contains(".mp4")
            || url.contains(".avi")) {
        // Video files
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "video/*");
    } else if (url.contains(".doc") || url.contains(".docx")) {
        // Word document
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "application/msword");
    }

    //if you want you can also define the intent type for any other file

    //additionally use else clause below, to manage other unknown extensions
    //in this case, Android will show all applications installed on the device
    //so you can choose which application to use

    else if (type.equals("none") || type.equals("*/*")) {
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, "*/*");
    } else {
        intent = new Intent(Intent.ACTION_VIEW);
        intent.setAction(Intent.ACTION_VIEW);
        intent.setDataAndType(uri, type);
    }

    //TRY Catch error
    try {
        this.cordova.getActivity().startActivity(intent);
    } catch (ActivityNotFoundException e) {
        intent.setData(uri);
        this.cordova.getActivity().startActivity(intent);
    }
}

From source file:com.HumanDecisionSupportSystemsLaboratory.DD_P2P.SendPK.java

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

    View view = inflater.inflate(R.layout.dialog_send_pk, container);

    Intent i = getActivity().getIntent();
    Bundle b = i.getExtras();/*from w  w w  .  j  a va 2s .  c o m*/
    safe_lid = b.getString(Safe.P_SAFE_LID);

    peer = D_Peer.getPeerByLID(safe_lid, true, false);
    if (peer == null) {
        Toast.makeText(getActivity(), "No peer. Reload!", Toast.LENGTH_SHORT).show();
        //finish();
    }

    exportByPhoto = (Button) view.findViewById(R.id.dialog_send_pk_export_by_picture);
    sendVia = (Button) view.findViewById(R.id.dialog_send_pk_send_via);

    getDialog().setTitle("Export public key");

    exportByPhoto.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if (Build.VERSION.SDK_INT < 19) {
                Intent intent = new Intent();
                intent.setType("image/*");
                intent.setAction(Intent.ACTION_GET_CONTENT);
                startActivityForResult(intent, SELECT_PHOTO);

                FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
                ft.detach(SendPK.this);
                ft.commit();
            } else {
                Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);
                intent.setType("image/*");
                startActivityForResult(intent, SELECT_PHOTO_KITKAT);
                FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
                ft.detach(SendPK.this);
                ft.commit();
            }
        }
    });

    sendVia.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (peer == null) {
                Toast.makeText(getActivity(), "No peer. Reload!", Toast.LENGTH_SHORT).show();
                return;
                //finish();
            }
            //DD_Address adr = new DD_Address(peer);

            String msgBody = DD.getExportTextObjectBody(peer); //adr.getBytes());

            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("text/plain");
            i.putExtra(Intent.EXTRA_TEXT, msgBody); //Safe.SAFE_TEXT_MY_BODY_SEP + Util.stringSignatureFromByte(adr.getBytes()));
            /*
                        String slogan = peer.getSlogan_MyOrDefault();
                        if (slogan == null) slogan = "";
                        else slogan = "\""+slogan+"\"";
                        i.putExtra(Intent.EXTRA_SUBJECT, "DDP2P: Safe Address of \""+peer.getName()+"\",  "+slogan+Safe.SAFE_TEXT_MY_HEADER_SEP);
            */
            i.putExtra(Intent.EXTRA_SUBJECT, DD.getExportTextObjectTitle(peer));
            i = Intent.createChooser(i, "send Public key");
            startActivity(i);
            FragmentTransaction ft = getActivity().getSupportFragmentManager().beginTransaction();
            ft.detach(SendPK.this);
            ft.commit();
        }
    });

    return view;
}

From source file:com.callrecorder.android.RecordingsAdapter.java

private void sendMail(String fileName) {
    DocumentFile file = FileHelper.getStorageFile(context).findFile(fileName);
    Uri uri = FileHelper.getContentUri(context, file.getUri());

    Intent sendIntent = new Intent(Intent.ACTION_SEND)
            .putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.mail_subject))
            .putExtra(Intent.EXTRA_TEXT, context.getString(R.string.mail_body))
            .putExtra(Intent.EXTRA_STREAM, uri).setData(uri).addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
            .setType("audio/3gpp");

    context.startActivity(Intent.createChooser(sendIntent, context.getString(R.string.send_mail)));
}

From source file:in.animeshpathak.nextbus.NextBusMain.java

/** Called when the activity is first started. */
@Override/*  w  w w. j ava  2  s  .  co m*/
public void onCreate(Bundle bundle) {
    Log.d(LOG_TAG, "entering onCreate()");
    SettingsActivity.setTheme(this);
    super.onCreate(bundle);
    setContentView(R.layout.main);

    try {
        busNet = BusNetwork.getInstance(this);
    } catch (Exception e) {
        Log.e(LOG_TAG, e.getMessage(), e);
        return;
    }

    // get the button
    // set handler to launch a processing dialog
    ImageButton updateButton = (ImageButton) findViewById(R.id.update_button);
    updateButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            BusLine selectedLine = lineAdapter.getItem(lineSpinner.getSelectedItemPosition());
            BusStop selectedStop = stopAdapter.getItem(stopSpinner.getSelectedItemPosition());
            getBusTimings(selectedLine, selectedStop);
        }
    });

    ImageButton feedbackButton = (ImageButton) findViewById(R.id.feedback_button);
    feedbackButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("message/rfc822"); // use from live device
            i.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.FEEDBACK_EMAIL_ADDRESS });
            i.putExtra(Intent.EXTRA_SUBJECT, Constants.FEEDBACK_EMAIL_SUBJECT);
            i.putExtra(Intent.EXTRA_TEXT, getString(R.string.email_hello));
            startActivity(Intent.createChooser(i, getString(R.string.select_email_app)));
        }
    });

    ImageButton phebusinfoButton = (ImageButton) findViewById(R.id.phebusinfo_button);
    phebusinfoButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog alertDialog = new AlertDialog.Builder(NextBusMain.this).create();
            WebView wv = new WebView(NextBusMain.this);
            new PhebusNewsLoader(wv, NextBusMain.this).execute();
            alertDialog.setView(wv);
            alertDialog.show();
        }
    });

    lineSpinner = (Spinner) findViewById(R.id.line_spinner);
    lineAdapter = new ArrayAdapter<BusLine>(this, android.R.layout.simple_spinner_item, busNet.getLines());
    lineAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    lineSpinner.setAdapter(lineAdapter);

    stopSpinner = (Spinner) findViewById(R.id.stop_spinner);
    stopAdapter = new ArrayAdapter<BusStop>(this, android.R.layout.simple_spinner_item);
    stopAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    stopSpinner.setAdapter(stopAdapter);

    ImageButton favoriteButton = (ImageButton) findViewById(R.id.favorites_button);
    favoriteButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            new FavoriteDialog(NextBusMain.this, new OnFavoriteSelectedListener() {
                @Override
                public void favoriteSelected(Favorite fav) {
                    BusLine bl = busNet.getLineByName(fav.getLine());
                    BusStop bs = bl.getFirstStopWithSimilarName(fav.getStop());
                    if (bl == null || bs == null) {
                        Log.e(LOG_TAG, "Favorite not found!");
                        return;
                    }
                    updateSpinners(bl, bs);
                    getBusTimings(bl, bs);
                }
            }, lineSpinner.getSelectedItem().toString(), stopSpinner.getSelectedItem().toString());
        }
    });
}

From source file:com.liato.bankdroid.banking.banks.Coop.java

@Override
public Urllib login() throws LoginException, BankException {
    try {/*from  w  ww.jav  a  2s .  com*/
        LoginPackage lp = preLogin();
        response = urlopen.open(lp.getLoginTarget(), lp.getPostData());
        if (response.contains("forfarande logga in med ditt personnummer")) {
            SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
            if (prefs.getBoolean("debug_mode", false) && prefs.getBoolean("debug_coop_sendmail", false)) {
                Intent i = new Intent(android.content.Intent.ACTION_SEND);
                i.setType("plain/text");
                i.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { "android@nullbyte.eu" });
                i.putExtra(android.content.Intent.EXTRA_SUBJECT, "Bankdroid - Coop Error");
                i.putExtra(android.content.Intent.EXTRA_TEXT, response);
                context.startActivity(i);
            }
            throw new LoginException(res.getText(R.string.invalid_username_password).toString());
        }
    } catch (ClientProtocolException e) {
        throw new BankException(e.getMessage());
    } catch (IOException e) {
        throw new BankException(e.getMessage());
    }
    return urlopen;
}

From source file:com.autburst.picture.FinishedUploadActivity.java

private void sendLink() {
    String url = createVideoUrl();
    if (url == null) {
        return;//w ww. ja va2 s .c o  m
    }
    Intent i = new Intent(Intent.ACTION_SEND);
    i.setType("text/plain");
    Resources res = getResources();
    i.putExtra(Intent.EXTRA_SUBJECT, res.getString(R.string.downloadlink));
    i.putExtra(Intent.EXTRA_TEXT, url);
    startActivity(Intent.createChooser(i, res.getString(R.string.sendlink)));
}

From source file:com.davidmiguel.gobees.apiaries.ApiariesActivity.java

/**
 * Opens send feedback option./* w w w .j av a2 s.c om*/
 */
private void openSendFeedback() {
    Intent emailIntent = new Intent(Intent.ACTION_SENDTO,
            Uri.parse("mailto:" + getString(R.string.gobees_email)));
    emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.gobees_email_subject));
    emailIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.gobees_email_body));
    startActivity(Intent.createChooser(emailIntent, getString(R.string.feedback_title)));
}

From source file:com.ferid.app.notetake.MainActivity.java

/**
 * Shares notes//from   w  w w  .  j av a2s .  c om
 */
private void shareNotes() {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.setType("text/plain");
    intent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.app_name));
    intent.putExtra(Intent.EXTRA_TEXT, notePad.getText().toString());

    startActivity(Intent.createChooser(intent, getString(R.string.share)));
}

From source file:com.google.android.demos.jamendo.app.ArtistActivity.java

private void share() {
    Cursor cursor = mHeaderAdapter.getCursor();
    if (cursor != null && cursor.moveToFirst()) {
        String idstr = cursor.getString(cursor.getColumnIndexOrThrow(Artists.IDSTR));
        String artistName = cursor.getString(cursor.getColumnIndexOrThrow(Artists.NAME));
        Uri uri = BASE_URI.buildUpon().appendPath(idstr).build();
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT, artistName);
        intent.putExtra(Intent.EXTRA_TEXT, String.valueOf(uri));
        intent = Intent.createChooser(intent, null);
        startActivity(intent);// w ww  .ja  va 2  s.  c  o  m
    }
}

From source file:co.taqat.call.AboutFragment.java

private void sendLogs(Context context, String info) {
    final String appName = context.getString(R.string.app_name);

    Intent i = new Intent(Intent.ACTION_SEND);
    i.putExtra(Intent.EXTRA_EMAIL, new String[] { context.getString(R.string.about_bugreport_email) });
    i.putExtra(Intent.EXTRA_SUBJECT, appName + " Logs");
    i.putExtra(Intent.EXTRA_TEXT, info);
    i.setType("application/zip");

    try {// w  w w  .  ja v a2  s  . com
        startActivity(Intent.createChooser(i, "Send mail..."));
    } catch (android.content.ActivityNotFoundException ex) {
        Log.e(ex);
    }
}