List of usage examples for android.content Intent EXTRA_STREAM
String EXTRA_STREAM
To view the source code for android.content Intent EXTRA_STREAM.
Click Source Link
From source file:li.barter.utils.Utils.java
private static void sendEmail(final Context context, final File attachment) { if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { final Uri path = Uri.fromFile(attachment); final Intent intent = new Intent(android.content.Intent.ACTION_SEND); intent.setType("application/octet-stream"); intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "barter.li database"); final String to[] = { "vinaysshenoy@gmail.com" }; intent.putExtra(Intent.EXTRA_EMAIL, to); intent.putExtra(Intent.EXTRA_TEXT, "Database"); intent.putExtra(Intent.EXTRA_STREAM, path); context.startActivity(Intent.createChooser(intent, "Send mail...")); } else {/*w ww. j av a 2 s . c o m*/ Logger.e(TAG, "Not mounted"); } }
From source file:com.raspi.chatapp.ui.chatting.ChatActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // The namespace I am using in the UploadService is the app id UploadService.NAMESPACE = BuildConfig.APPLICATION_ID; // the layout contains just the toolbar and the FrameLayout which // contains every fragment setContentView(R.layout.activity_chat); // manage the backstack, therefore, I got a function that checks whether I // can go back and sets the back button in the actionbar accordingly getSupportFragmentManager().addOnBackStackChangedListener(this); shouldDisplayHomeUp();//from ww w . ja v a2 s .c om // in case this is the first time the app launches or in case the user // deleted all application data set my buddyId and pwd I use to log into // the XMPP server setUserPwd(); // if there is a calling intent and this contains a buddyId and chatName // do not open the chatFragmet instantly but only set the current // variables in order to be able to ask for a password if necessary, see // onResume. Intent callingIntent = getIntent(); Bundle extras = callingIntent.getExtras(); String type = callingIntent.getType(); if (Intent.ACTION_SEND.equals(callingIntent.getAction()) && type != null) { if (type.startsWith("image/")) { imageUri = callingIntent.getParcelableExtra(Intent.EXTRA_STREAM); } } if (extras != null && extras.containsKey(Constants.BUDDY_ID) && extras.containsKey(Constants.CHAT_NAME)) { currentBuddyId = extras.getString(Constants.BUDDY_ID); currentChatName = extras.getString(Constants.CHAT_NAME); } }
From source file:com.hijacker.FeedbackDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); dialogView = getActivity().getLayoutInflater().inflate(R.layout.feedback_dialog, null); emailView = (EditText) dialogView.findViewById(R.id.email_et); include_report = (CheckBox) dialogView.findViewById(R.id.include_report); feedbackView = (EditText) dialogView.findViewById(R.id.feedback_et); progress = (ProgressBar) dialogView.findViewById(R.id.progress); emailView.setText(pref.getString("user_email", "")); emailView.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override/*from w ww. j av a 2 s . c o m*/ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_NEXT) { feedbackView.requestFocus(); return true; } return false; } }); report = null; include_report.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked && report == null) { progress.setIndeterminate(true); new Thread(new Runnable() { @Override public void run() { report = new File(Environment.getExternalStorageDirectory() + "/report.txt"); if (!createReport(report, path, null, Shell.getFreeShell().getShell())) { if (debug) Log.e("HIJACKER/feedbackDialog", "Report not generated"); report = null; } runInHandler(new Runnable() { @Override public void run() { progress.setIndeterminate(false); } }); } }).start(); } } }); builder.setView(dialogView); builder.setTitle(getString(R.string.feedback)); builder.setPositiveButton(R.string.send, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); builder.setNeutralButton(R.string.send_email, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("plain/text"); intent.putExtra(Intent.EXTRA_EMAIL, new String[] { "kiriakopoulos44@gmail.com" }); intent.putExtra(Intent.EXTRA_SUBJECT, "Hijacker feedback"); if (report != null) { Uri attachment = FileProvider.getUriForFile( FeedbackDialog.this.getActivity().getApplicationContext(), BuildConfig.APPLICATION_ID + ".provider", report); intent.putExtra(Intent.EXTRA_STREAM, attachment); } intent.putExtra(Intent.EXTRA_TEXT, feedbackView.getText().toString()); startActivity(intent); } }); return builder.create(); }
From source file:com.codebutler.farebot.fragment.CardsFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { ClipboardManager clipboardManager = (ClipboardManager) getActivity() .getSystemService(Context.CLIPBOARD_SERVICE); try {/*from w ww.j av a 2 s.co m*/ int itemId = item.getItemId(); switch (itemId) { case R.id.import_file: Intent target = new Intent(Intent.ACTION_GET_CONTENT); target.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(Environment.getExternalStorageDirectory())); target.setType("*/*"); startActivityForResult(Intent.createChooser(target, getString(R.string.select_file)), REQUEST_SELECT_FILE); return true; case R.id.import_clipboard: ClipData clip = clipboardManager.getPrimaryClip(); if (clip != null && clip.getItemCount() > 0) { String text = clip.getItemAt(0).coerceToText(getActivity()).toString(); onCardsImported(mExportHelper.importCards(text)); } return true; case R.id.copy: clipboardManager.setPrimaryClip(ClipData.newPlainText(null, mExportHelper.exportCards())); Toast.makeText(getActivity(), R.string.copied_to_clipboard, Toast.LENGTH_SHORT).show(); return true; case R.id.share: Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, mExportHelper.exportCards()); startActivity(intent); return true; case R.id.save: exportToFile(); return true; } } catch (Exception ex) { Utils.showError(getActivity(), ex); } return false; }
From source file:jackpal.androidterm.RemoteInterface.java
protected void handleIntent() { TermService service = getTermService(); if (service == null) { finish();/*from w ww . ja v a2 s.co m*/ return; } Intent myIntent = getIntent(); String action = myIntent.getAction(); if (action == null) { finish(); return; } ClipData clipData = myIntent.getClipData(); if ((AndroidCompat.SDK >= 19 && action.equals(Intent.ACTION_SEND) && myIntent.hasExtra(Intent.EXTRA_STREAM)) || (action.equals(Intent.ACTION_SEND) && clipData != null) || (action.equals("android.intent.action.VIEW")) || (action.equals("android.intent.action.EDIT")) || (action.equals("android.intent.action.PICK")) || (action.equals("com.googlecode.android_scripting.action.EDIT_SCRIPT"))) { String url = null; Uri uri = null; if (clipData != null) { uri = clipData.getItemAt(0).getUri(); if (uri == null) { openText(clipData.getItemAt(0).getText()); finish(); return; } } else if (AndroidCompat.SDK >= 19 && action.equals(Intent.ACTION_SEND) && myIntent.hasExtra(Intent.EXTRA_STREAM)) { Object extraStream = myIntent.getExtras().get(Intent.EXTRA_STREAM); if (extraStream instanceof Uri) { uri = (Uri) extraStream; } } else { uri = myIntent.getData(); } String intentCommand = "sh "; if (mSettings.getInitialCommand().matches("(.|\n)*(^|\n)-vim\\.app(.|\n)*")) { intentCommand = ":e "; } boolean flavorVim = intentCommand.matches("^:.*"); if (uri != null && uri.toString().matches("^file:///.*") && flavorVim) { String path = uri.getPath(); if (new File(path).canRead()) { path = path.replaceAll(Term.SHELL_ESCAPE, "\\\\$1"); String command = "\u001b" + intentCommand + path; // Find the target window mReplace = true; mHandle = switchToWindow(mHandle, command); mReplace = false; } finish(); } else if (AndroidCompat.SDK >= 19 && uri != null && uri.getScheme() != null && uri.getScheme().equals("content") && flavorVim) { Context context = this; String command = null; String path = Term.getPath(context, uri); if (path != null) { path = path.replaceAll(Term.SHELL_ESCAPE, "\\\\$1"); command = "\u001b" + intentCommand + path; } else if (getContentResolver() != null) { try { Cursor cursor = getContentResolver().query(uri, null, null, null, null, null); path = Term.handleOpenDocument(uri, cursor); } catch (Exception e) { alert(e.toString() + "\n" + this.getString(R.string.storage_read_error)); finish(); } if (path == null) { alert(this.getString(R.string.storage_read_error)); finish(); } else { File dir = Term.getScratchCacheDir(this); SyncFileObserver sfo = new SyncFileObserver(path); sfo.setConTentResolver(this.getContentResolver()); path = dir.toString() + path; String fname = new File(path).getName(); if (path.equals("") || !sfo.putUriAndLoad(uri, path)) { alert(fname + "\n" + this.getString(R.string.storage_read_error)); finish(); } path = path.replaceAll(Term.SHELL_ESCAPE, "\\\\$1"); command = "\u001b" + intentCommand + path; } } // Find the target window mReplace = true; mHandle = switchToWindow(mHandle, command); mReplace = false; finish(); } else if (action.equals("com.googlecode.android_scripting.action.EDIT_SCRIPT")) { url = myIntent.getExtras().getString("com.googlecode.android_scripting.extra.SCRIPT_PATH"); } else if (myIntent.getScheme() != null && myIntent.getScheme() != null && myIntent.getScheme().equals("file")) { if (myIntent.getData() != null) url = myIntent.getData().getPath(); } if (url != null) { String command = "sh "; if (mSettings.getInitialCommand().matches("(.|\n)*(^|\n)-vim\\.app(.|\n)*")) { command = ":e "; } if (command.matches("^:.*")) { url = url.replaceAll(Term.SHELL_ESCAPE, "\\\\$1"); command = "\u001b" + command + url; // Find the target window mReplace = true; mHandle = switchToWindow(mHandle, command); mReplace = false; } else if ((mHandle != null) && (url.equals(mFname))) { // Target the request at an existing window if open command = command + url; mHandle = switchToWindow(mHandle, command); } else { // Open a new window command = command + url; mHandle = openNewWindow(command); } mFname = url; Intent result = new Intent(); result.putExtra(EXTRA_WINDOW_HANDLE, mHandle); setResult(RESULT_OK, result); } } else if (action.equals(Intent.ACTION_SEND) && myIntent.hasExtra(Intent.EXTRA_TEXT)) { openText(myIntent.getExtras().getCharSequence(Intent.EXTRA_TEXT)); } else { } finish(); }
From source file:info.wncwaterfalls.app.FullScreenImageActivity.java
private Intent getDefaultShareIntent() { // Copy the image to the media store for sharing. Uri media_store_uri;/* ww w .j ava 2 s. c o m*/ boolean failed = false; // See if image is already in media store String[] projection = { MediaStore.Images.Media._ID }; String selection = MediaStore.Images.Media.TITLE + "=?"; String[] selectionArgs = { mWaterfallName }; Cursor c = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, projection, selection, selectionArgs, null); if (c != null && c.getCount() > 0) { c.moveToFirst(); media_store_uri = Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, c.getString(0)); } else { ContentValues values = new ContentValues(); values.put(MediaStore.Images.Media.TITLE, mWaterfallName); values.put(MediaStore.Images.Media.DESCRIPTION, "This is " + mWaterfallName + "."); values.put(MediaStore.Images.Media.MIME_TYPE, "image/jpeg"); media_store_uri = getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values); // Open bitmap and recompress directly to media store. Bitmap bitmap = BitmapFactory.decodeResource(getResources(), mImgResourceId); OutputStream stream; try { stream = getContentResolver().openOutputStream(media_store_uri); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream); stream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); failed = true; } catch (IOException e) { e.printStackTrace(); failed = true; } // Done copying image to media store. Recycle it. bitmap.recycle(); bitmap = null; } // Safe to display image now populateImageView(); // Create intent and add image to it Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("image/jpeg"); intent.putExtra(Intent.EXTRA_SUBJECT, "Photo from WNCWaterfalls.info"); intent.putExtra(Intent.EXTRA_TEXT, "This is " + mWaterfallName + "."); if (!failed) { intent.putExtra(Intent.EXTRA_STREAM, media_store_uri); } else { Context context = getApplicationContext(); CharSequence text = "Oops...couldn't add image attachment :("; int duration = Toast.LENGTH_SHORT; Toast toast = Toast.makeText(context, text, duration); toast.show(); } return intent; }
From source file:com.microsoft.rightsmanagement.sampleapp.App.java
/** * Send file./*from w ww . j av a 2s .co m*/ * * @param activity the activity * @param filePath the file path */ static void sendFile(Activity activity, String filePath) { // New intent to open mail client. Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_SEND); if (isPTxtFile(filePath) || isTxt2File(filePath)) { intent.setType("application/octet-stream"); } else { intent.setType("plain/text"); } intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + filePath)); activity.startActivity(Intent.createChooser(intent, "Sending File...")); }
From source file:br.com.anteros.vendas.gui.ManutencaoTabelasActivity.java
private void selecionarArquivoCompartilhar() { File importFolder = new File(Environment.getExternalStorageDirectory() + "/backup/"); final File importFiles[] = importFolder.listFiles(); if (importFiles == null || importFiles.length == 0) { Toast.makeText(this, "Pasta de backup vazia", Toast.LENGTH_SHORT).show(); return;//from ww w . j av a 2s .c om } AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Selecionar arquivo:"); builder.setSingleChoiceItems(importFolder.list(), 0, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { File importDatabaseFile = importFiles[whichButton]; Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("*/*"); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "File Name"); emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(importDatabaseFile)); startActivity(Intent.createChooser(emailIntent, "Share File")); dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:justforcommunity.radiocom.activities.ContentDetail.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(); //noinspection SimplifiableIfStatement switch (id) { case R.id.home: finish();/*from w w w . j a v a2 s .c om*/ break; case R.id.menu_item_share: Uri imageUri = null; try { imageUri = Uri.parse(MediaStore.Images.Media.insertImage(this.getContentResolver(), BitmapFactory.decodeResource(getResources(), R.drawable.logo_nav_header), null, null)); } catch (NullPointerException e) { } Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_STREAM, imageUri); shareIntent.putExtra(Intent.EXTRA_TEXT, title + " " + getResources().getText(R.string.share_via)); shareIntent.setType("image/*"); startActivity(Intent.createChooser(shareIntent, getResources().getText(R.string.share_send_to))); break; default: return true; } return super.onOptionsItemSelected(item); }