List of usage examples for android.content Intent setType
public @NonNull Intent setType(@Nullable String type)
From source file:de.electricdynamite.pasty.ClipboardFragment.java
@SuppressLint("NewApi") public boolean onContextItemSelected(android.view.MenuItem item) { AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo(); int menuItemIndex = item.getItemId(); ClipboardItem Item = mItems.get(info.position); switch (menuItemIndex) { case PastySharedStatics.ITEM_CONTEXTMENU_COPY_ID: // Copy without exit selected if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSherlockActivity() .getSystemService(Context.CLIPBOARD_SERVICE); Item.copyToClipboard(clipboard); clipboard = null;//ww w . ja v a 2s . com } else { ClipboardManager clipboard = (ClipboardManager) getSherlockActivity() .getSystemService(Context.CLIPBOARD_SERVICE); Item.copyToClipboard(clipboard); clipboard = null; } Toast.makeText(getSherlockActivity().getApplicationContext(), getString(R.string.item_copied), Toast.LENGTH_LONG).show(); break; case PastySharedStatics.ITEM_CONTEXTMENU_SHARE_ID: // Share to another app Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, Item.getText()); startActivity(Intent.createChooser(shareIntent, getString(R.string.app_share_from_pasty))); break; case PastySharedStatics.ITEM_CONTEXTMENU_DELETE_ID: // Delete selected mAdapter.delete(info.position); break; case PastySharedStatics.ITEM_CONTEXTMENU_OPEN_ID: /* If the clicked item was originally linkified, we * fire an ACTION_VIEW intent. */ String url = Item.getText(); if (!URLUtil.isValidUrl(url)) url = "http://" + url; Intent i = new Intent(Intent.ACTION_VIEW); i.setData(Uri.parse(url)); startActivity(i); break; } return true; }
From source file:com.orange.ocara.ui.activity.ListAuditActivity.java
private void createNewDocument(String path) { Intent intent = new Intent(Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); intent.setType( MimeTypeMap.getSingleton().getMimeTypeFromExtension(MimeTypeMap.getFileExtensionFromUrl(path))); startActivityForResult(intent, ACTION_CREATE_NEW_DOCUMENT); }
From source file:pl.bcichecki.rms.client.android.fragments.EventsListFragment.java
private void performActionShare(ActionMode mode, MenuItem item, Event selectedEvent) { ShareActionProvider shareActionProvider = (ShareActionProvider) item.getActionProvider(); if (shareActionProvider != null) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType(AppConstants.CONTENT_TEXT_PLAIN); intent.putExtra(android.content.Intent.EXTRA_TEXT, new EventTextPrettyPrinter(getActivity()).print(selectedEvent)); shareActionProvider.setShareHistoryFileName(null); shareActionProvider.setShareIntent(intent); Log.d(TAG, "Event " + selectedEvent + " was succesfully shared."); }/* w w w. j a v a 2s . co m*/ }
From source file:com.wikitude.virtualhome.AugmentedActivity.java
public void setBkgImage() { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Select Picture"), SELECT_PICTURE); }
From source file:com.irccloud.android.activity.ImageViewerActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_imageviewer, menu); if (getIntent() != null && getIntent().getDataString() != null) { Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse( getIntent().getDataString().replace(getResources().getString(R.string.IMAGE_SCHEME), "http"))); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, getIntent().getDataString().replace(getResources().getString(R.string.IMAGE_SCHEME), "http")); intent.putExtra(ShareCompat.EXTRA_CALLING_PACKAGE, getPackageName()); intent.putExtra(ShareCompat.EXTRA_CALLING_ACTIVITY, getPackageManager().getLaunchIntentForPackage(getPackageName()).getComponent()); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET | Intent.FLAG_ACTIVITY_NEW_TASK); MenuItem shareItem = menu.findItem(R.id.action_share); ShareActionProviderHax share = (ShareActionProviderHax) MenuItemCompat.getActionProvider(shareItem); share.onShareActionProviderSubVisibilityChangedListener = this; share.setShareIntent(intent);//from w ww . j av a 2 s .c o m } return true; }
From source file:com.dileepindia.cordova.sms.SMSPlugin.java
public void invokeSMSIntent(String phoneNumber, String message) { Intent sendIntent = new Intent(Intent.ACTION_VIEW); sendIntent.putExtra("sms_body", message); sendIntent.setType("vnd.android-dir/mms-sms"); activity.startActivity(sendIntent);// w ww. j a v a 2 s . c o m }
From source file:com.richtodd.android.quiltdesign.app.BlockEditActivity.java
@Override public void onShareOptionsPositiveClick(DialogFragment dialog, RenderStyles renderStyle, RenderFormats renderFormat, String intentAction) throws Exception { Uri uriFile;//from w w w .ja va 2 s . com String type; switch (renderFormat) { case Bitmap: uriFile = saveBitmap(renderStyle); type = "image/png"; break; case PDF: uriFile = savePDF(renderStyle); type = "application/pdf"; break; case QuiltDesign: uriFile = saveQuiltDesign(); type = "application/vnd.richtodd.quiltdesign"; break; default: throw new IllegalArgumentException("Unknown render format " + renderFormat); } Intent intent = new Intent(intentAction); if (intentAction.equals(Intent.ACTION_SEND)) { intent.putExtra(Intent.EXTRA_STREAM, uriFile); intent.setType(type); startActivity(Intent.createChooser(intent, "Share With")); } else { intent.setDataAndType(uriFile, type); startActivity(Intent.createChooser(intent, "View With")); } }
From source file:br.com.anteros.vendas.gui.AnexoCadastroActivity.java
/** * Seleciona um arquivo do tipo imagem para anexar *//*from www. j av a 2 s . com*/ private void selecionarImagem() { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, "Selecione"), SELECIONAR_ARQUIVO); }
From source file:org.bwgz.quotation.activity.QuotationActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { boolean result = false; switch (item.getItemId()) { case R.id.actionbar_back: { Log.d(TAG, String.format("onOptionsItemSelected - actionbar_back")); if (history.hasBack()) { loadQuote(history.back());//from w ww . j ava 2s .com } menu.findItem(R.id.actionbar_back).setEnabled(history.hasBack()); menu.findItem(R.id.actionbar_forward).setEnabled(history.hasForward()); EasyTracker.getInstance(this) .send(MapBuilder.createEvent("ui_action", "button_press", "menu_back", null).build()); result = true; break; } case R.id.actionbar_forward: { Log.d(TAG, String.format("onOptionsItemSelected - actionbar_forward")); if (history.hasForward()) { loadQuote(history.forward()); } menu.findItem(R.id.actionbar_back).setEnabled(history.hasBack()); menu.findItem(R.id.actionbar_forward).setEnabled(history.hasForward()); EasyTracker.getInstance(this) .send(MapBuilder.createEvent("ui_action", "button_press", "menu_forward", null).build()); result = true; break; } case R.id.actionbar_new: { loadRandomQuote(); EasyTracker.getInstance(this) .send(MapBuilder.createEvent("ui_action", "button_press", "menu_new", null).build()); result = true; break; } case R.id.actionbar_share: { CharSequence text = ((TextView) findViewById(R.id.quotation)).getText(); if (text != null && text.length() != 0) { StringBuilder buffer = new StringBuilder(); buffer.append(text); text = ((TextView) findViewById(R.id.author)).getText(); if (text != null && text.length() != 0) { buffer.append(" ... "); buffer.append(text); } Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, buffer.toString()); startActivity(Intent.createChooser(intent, getResources().getText(R.string.sharing_quote))); } EasyTracker.getInstance(this) .send(MapBuilder.createEvent("ui_action", "button_press", "menu_share", null).build()); result = true; break; } case R.id.settings: { Intent intent = new Intent().setClass(this, SettingsActivity.class); startActivity(intent); EasyTracker.getInstance(this) .send(MapBuilder.createEvent("ui_action", "button_press", "menu_settings", null).build()); result = true; break; } } return result; }
From source file:bizapps.com.healthforusPatient.activity.RegisterActivity.java
private void galleryIntent() { Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT);// startActivityForResult(Intent.createChooser(intent, "Select File"), SELECT_FILE); }