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:net.xisberto.work_schedule.history.ViewHistoryActivity.java
@Override public void shareUri(Uri uri) { Log.d("History", "shareURI"); if (uri == null) { new AlertDialog.Builder(this).setTitle(R.string.app_name).setMessage(R.string.txt_no_data) .setPositiveButton(android.R.string.ok, null).show(); return;/*from ww w . j a va 2s . c o m*/ } Intent intentShare = new Intent(Intent.ACTION_SEND); intentShare.setType("text/csv"); intentShare.putExtra(Intent.EXTRA_STREAM, uri); startActivity(Intent.createChooser(intentShare, getResources().getString(R.string.menu_share))); }
From source file:de.golov.zeitgeistreich.ZeitGeistReichActivity.java
/** Called when the activity is first created. */ @Override/*from w w w .ja v a2 s . co m*/ public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); final ImageView imagePreview = (ImageView) findViewById(R.id.ImagePreview); Intent intent = getIntent(); Bundle extras = intent.getExtras(); Uri mImageUri = null; if (Intent.ACTION_SEND.equals(intent.getAction()) && extras != null) { if (extras.containsKey(Intent.EXTRA_STREAM)) { mImageUri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM); if (mImageUri != null) { int origId = Integer.parseInt(mImageUri.getLastPathSegment()); Bitmap bitmap = MediaStore.Images.Thumbnails.getThumbnail(getContentResolver(), origId, MediaStore.Images.Thumbnails.MINI_KIND, (BitmapFactory.Options) null); imagePreview.setImageBitmap(bitmap); } } } ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, tag_suggests); final MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.TagEditView); textView.setAdapter(adapter); textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); final Button button = (Button) findViewById(R.id.ZeitgeistSubmit); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { submitImage(textView.getText().toString()); } }); }
From source file:com.nttec.everychan.ui.ShareActivity.java
private void handleIntent(Intent intent) { ArrayAdapter<Pair<TabModel, SerializablePage>> adapter = new ArrayAdapter<Pair<TabModel, SerializablePage>>( this, 0) { private final int drawablePadding = (int) (getResources().getDisplayMetrics().density * 5 + 0.5f); @Override//from w w w .j ava2s .c om public View getView(int position, View convertView, ViewGroup parent) { View view = convertView == null ? getLayoutInflater().inflate(android.R.layout.simple_list_item_1, parent, false) : convertView; TextView tv = (TextView) view.findViewById(android.R.id.text1); tv.setEllipsize(TextUtils.TruncateAt.END); tv.setSingleLine(); tv.setText(getItem(position).getLeft().title); tv.setCompoundDrawablesWithIntrinsicBounds(MainApplication.getInstance() .getChanModule(getItem(position).getLeft().pageModel.chanName).getChanFavicon(), null, null, null); tv.setCompoundDrawablePadding(drawablePadding); return view; } }; for (TabModel tab : MainApplication.getInstance().tabsState.tabsArray) { if (tab.type == TabModel.TYPE_NORMAL && tab.pageModel.type != UrlPageModel.TYPE_SEARCHPAGE) { SerializablePage page = MainApplication.getInstance().pagesCache.getSerializablePage(tab.hash); if (page != null) { adapter.add(Pair.of(tab, page)); } } } if (adapter.getCount() == 0) { for (Database.HistoryEntry entity : MainApplication.getInstance().database.getHistory()) { try { TabModel tab = new TabModel(); tab.title = entity.title; tab.type = TabModel.TYPE_NORMAL; tab.webUrl = entity.url; tab.pageModel = UrlHandler.getPageModel(entity.url); tab.hash = ChanModels.hashUrlPageModel(tab.pageModel); SerializablePage page = MainApplication.getInstance().pagesCache.getSerializablePage(tab.hash); if (page != null) { adapter.add(Pair.of(tab, page)); } } catch (Exception e) { Logger.e(TAG, e); } } if (adapter.getCount() == 0) { Toast.makeText(this, R.string.share_no_tabs, Toast.LENGTH_LONG).show(); finish(); return; } } if (PostingService.isNowPosting()) { Toast.makeText(this, R.string.posting_now_posting, Toast.LENGTH_LONG).show(); finish(); return; } selectedFile = null; if (intent != null) { Uri uri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (uri != null) { File file = UriFileUtils.getFile(this, uri); if (file != null) { selectedFile = file; } } } if (selectedFile == null) { Toast.makeText(this, R.string.postform_cannot_attach, Toast.LENGTH_LONG).show(); finish(); return; } setListAdapter(adapter); }
From source file:com.odoo.base.ir.Attachment.java
public List<ODataRow> handleMultipleResult(Intent data) { List<ODataRow> attachments = new ArrayList<ODataRow>(); ArrayList<Uri> fileUris = data.getParcelableArrayListExtra(Intent.EXTRA_STREAM); for (Uri uri : fileUris) { attachments.add(uriToDataRow(uri, null)); }/*w ww . j ava 2s .c o m*/ return attachments; }
From source file:com.frankegan.sqrshare.MainActivity.java
/** * A helper method for when an app shares an {@link android.content.Intent} to be opened by our app. * It changes the {@link android.widget.ImageView} to the image of the given intent. * * @param intent The {@link android.content.Intent} of the image to be displayed. *///from www . j a v a 2s . c o m private void handleSentImage(Intent intent) { Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); if (imageUri != null) try { holder = SqrBitmapGenerator.generate(this, imageUri); } catch (IOException e) { e.printStackTrace(); Log.i("frankegan", "IOException" + e.toString()); } else Log.i("frankegan", "bad intent"); }
From source file:com.dwdesign.gallery3d.app.ImageViewerGLActivity.java
@Override public void onClick(final View view) { final Uri uri = getIntent().getData(); switch (view.getId()) { case R.id.close: { onBackPressed();/* w w w . j a v a 2 s. c om*/ break; } case R.id.refresh_stop_save: { final LoaderManager lm = getSupportLoaderManager(); if (!mImageLoaded && !lm.hasRunningLoaders()) { loadImage(); } else if (!mImageLoaded && lm.hasRunningLoaders()) { stopLoading(); } else if (mImageLoaded) { new SaveImageTask(this, mImageFile).execute(); } break; } case R.id.share: { if (uri == null) { break; } final Intent intent = new Intent(Intent.ACTION_SEND); if (mImageFile != null && mImageFile.exists()) { intent.setType("image/*"); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(mImageFile)); } else { intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, uri.toString()); } startActivity(Intent.createChooser(intent, getString(R.string.share))); break; } case R.id.open_in_browser: { if (uri == null) { break; } final String scheme = uri.getScheme(); if ("http".equals(scheme) || "https".equals(scheme)) { final Intent intent = new Intent(Intent.ACTION_VIEW, uri); intent.addCategory(Intent.CATEGORY_BROWSABLE); try { startActivity(intent); } catch (final ActivityNotFoundException e) { // Ignore. } } break; } } }
From source file:de.evilbrain.sendtosftp.Main.java
@SuppressLint("NewApi") private void handlePushFromApp() { // Push to this app Intent intent = getIntent();/*from w ww .j a v a 2 s. c o m*/ String type = intent.getType(); if (type != null) { // Set all visible fileNameText.setVisibility(View.VISIBLE); fileName.setVisibility(View.VISIBLE); imagePreview.setVisibility(View.VISIBLE); buttonSend.setVisibility(View.VISIBLE); // get Content String contentString = ""; Object content = null; if (android.os.Build.VERSION.SDK_INT > 16) { content = intent.getClipData().getItemAt(0).getUri(); contentString = content.toString(); } else { content = intent.getExtras().get(Intent.EXTRA_STREAM); contentString = content.toString(); } // set filename fileName.setText(contentString); // Preview Image if (type.contains("image")) { imagePreview.setImageURI((Uri) content); } } }
From source file:com.pixby.texo.MainActivity.java
private void handleImageOpenIntent(Intent intent) { if (intent != null) { Tracker.trackSimpleEvent(this, Tracker.Event.LOAD_IMAGE); Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM); loadImage(imageUri, mStageView); mEditPresenter.setImageChanged(true); }//from w w w .jav a 2 s .c om }
From source file:com.openerp.base.ir.Attachment.java
public List<OEDataRow> handleMultipleResult(Intent data) { List<OEDataRow> attachments = new ArrayList<OEDataRow>(); ArrayList<Uri> fileUris = data.getParcelableArrayListExtra(Intent.EXTRA_STREAM); for (Uri uri : fileUris) { attachments.add(uriToDataRow(uri, null)); }/* w w w. ja v a2 s .c o m*/ return attachments; }
From source file:info.papdt.blacklight.ui.common.ImageActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if (id == android.R.id.home) { finish();/* w ww. j av a 2s. co m*/ return true; } else if (id == R.id.save || id == R.id.share) { int current = mPager.getCurrentItem(); if (!mLoaded[current]) { Toast.makeText(this, R.string.not_loaded, Toast.LENGTH_SHORT).show(); } else { String path = mApiCache.saveLargePic(mModel, current); if (id == R.id.save) { if (path == null) { Toast.makeText(this, R.string.save_failed, Toast.LENGTH_SHORT).show(); } else { String msg = String.format(getResources().getString(R.string.saved_to), path); Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); } } if (id == R.id.share) { if (path != null) { File f = new File(path); Uri u = Uri.fromFile(f); ShareActionProvider share = (ShareActionProvider) MenuItemCompat.getActionProvider(item); Intent i = new Intent(); i.setAction(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_STREAM, u); i.setType("image/*"); share.setShareIntent(i); } } } return true; } else { return super.onOptionsItemSelected(item); } }