List of usage examples for android.content Intent setType
public @NonNull Intent setType(@Nullable String type)
From source file:de.jamoo.muzei.WallSource.java
@Override public void onCustomCommand(int id) { super.onCustomCommand(id); if (id == COMMAND_ID_SHARE) { Artwork currentArtwork = getCurrentArtwork(); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); Uri artUrl = currentArtwork.getImageUri(); if (DEBUG) Log.d(TAG, "artUrl: " + artUrl); String author = currentArtwork.getByline(); if (DEBUG) Log.d(TAG, "author: " + author); String playUrl = "http://play.google.com/store/apps/details?id=" + getPackageName(); if (DEBUG) Log.d(TAG, "playUrl: " + playUrl); shareIntent.putExtra(Intent.EXTRA_TEXT, "My wallpaper today is " + currentArtwork.getTitle() + " by " + author + " \n" + artUrl + " \n" + "from the " + getString(R.string.app_name) + " app\n" + "Get it now on the PlayStore! " + playUrl); shareIntent = Intent.createChooser(shareIntent, "Share Wallpaper"); shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(shareIntent);//from w ww .ja v a 2 s. com } }
From source file:com.granita.contacticloudsync.ui.DebugInfoActivity.java
public void onShare(MenuItem item) { if (!TextUtils.isEmpty(report)) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.setType("text/plain"); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Exception Details"); try {//from w ww . ja va 2s .c o m File reportFile = File.createTempFile("debug", ".txt", getExternalCacheDir()); Constants.log.debug("Writing debug info to " + reportFile.getAbsolutePath()); FileWriter writer = new FileWriter(reportFile); writer.write(report); writer.close(); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(reportFile)); } catch (IOException e) { // let's hope the report is < 1 MB sendIntent.putExtra(Intent.EXTRA_TEXT, report); } startActivity(sendIntent); } }
From source file:com.phonegap.CameraLauncher.java
/** * Get image from photo library./* ww w.j a va2 s . co m*/ * * @param quality Compression quality hint (0-100: 0=low quality & high compression, 100=compress of max quality) * @param srcType The album to get image from. * @param returnType Set the type of image to return. */ // TODO: Images selected from SDCARD don't display correctly, but from CAMERA ALBUM do! public void getImage(int quality, int srcType, int returnType) { this.mQuality = quality; Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); intent.addCategory(Intent.CATEGORY_OPENABLE); this.ctx.startActivityForResult((Plugin) this, Intent.createChooser(intent, new String("Get Picture")), (srcType + 1) * 16 + returnType + 1); }
From source file:id.zelory.tanipedia.activity.BacaActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_baca); tmp = getIntent().getParcelableExtra("berita"); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);/*from w w w. ja v a2 s . c o m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar); collapsingToolbar.setTitle("TaniPedia"); animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow); gambar = (ImageView) findViewById(R.id.gambar); judul = (TextView) findViewById(R.id.judul); tanggal = (TextView) findViewById(R.id.tanggal); isi = (DocumentView) findViewById(R.id.isi); root = (LinearLayout) findViewById(R.id.ll_root_berita); fabButton = (FabButton) findViewById(R.id.determinate); fabButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, berita.getJudul()); intent.putExtra(Intent.EXTRA_TEXT, berita.getJudul() + "\n" + berita.getAlamat()); startActivity(Intent.createChooser(intent, "Bagikan")); } }); generateBeritaLainnya(); new DownloadData().execute(); }
From source file:com.google.android.apps.muzei.featuredart.FeaturedArtSource.java
@Override protected void onCustomCommand(int id) { super.onCustomCommand(id); if (COMMAND_ID_SHARE == id) { Artwork currentArtwork = getCurrentArtwork(); if (currentArtwork == null) { LOGW(TAG, "No current artwork, can't share."); new Handler(Looper.getMainLooper()).post(new Runnable() { @Override//www. j av a 2 s. co m public void run() { Toast.makeText(FeaturedArtSource.this, R.string.featuredart_source_error_no_artwork_to_share, Toast.LENGTH_SHORT).show(); } }); return; } String detailUrl = ("initial".equals(currentArtwork.getToken())) ? "http://www.wikipaintings.org/en/vincent-van-gogh/the-starry-night-1889" : currentArtwork.getViewIntent().getDataString(); String artist = currentArtwork.getByline().replaceFirst("\\.\\s*($|\\n).*", "").trim(); Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, "My Android wallpaper today is '" + currentArtwork.getTitle().trim() + "' by " + artist + ". #MuzeiFeaturedArt\n\n" + detailUrl); shareIntent = Intent.createChooser(shareIntent, "Share artwork"); shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(shareIntent); } else if (COMMAND_ID_DEBUG_INFO == id) { long nextUpdateTimeMillis = getSharedPreferences().getLong("scheduled_update_time_millis", 0); final String nextUpdateTime; if (nextUpdateTimeMillis > 0) { Date d = new Date(nextUpdateTimeMillis); nextUpdateTime = SimpleDateFormat.getDateTimeInstance().format(d); } else { nextUpdateTime = "None"; } new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { Toast.makeText(FeaturedArtSource.this, "Next update time: " + nextUpdateTime, Toast.LENGTH_LONG) .show(); } }); } }
From source file:com.xengar.android.booksearch.ui.BookDetailActivity.java
private void setShareIntent() { ImageView ivImage = (ImageView) findViewById(R.id.ivBookCover); final TextView tvTitle = (TextView) findViewById(R.id.tvTitle); // Get access to the URI for the bitmap Uri bmpUri = getLocalBitmapUri(ivImage); // Construct a ShareIntent with link to image Intent shareIntent = new Intent(); // Construct a ShareIntent with link to image shareIntent.setAction(Intent.ACTION_SEND); shareIntent.setType("*/*"); shareIntent.putExtra(Intent.EXTRA_TEXT, (String) tvTitle.getText()); shareIntent.putExtra(Intent.EXTRA_STREAM, bmpUri); // Launch share menu startActivity(Intent.createChooser(shareIntent, "Share Image")); }
From source file:com.galois.qrstream.lib.DecodeThread.java
private Intent buildIntent(Job message) throws IOException { Intent i = new Intent(); i.setAction(Intent.ACTION_SEND);/* w w w .j a va 2 s.c om*/ i.addCategory(Intent.CATEGORY_DEFAULT); String mimeType = message.getMimeType(); i.setType(mimeType); if (mimeType.equals("text/plain")) { String msg = new String(message.getData()); i.putExtra(Intent.EXTRA_TEXT, msg); } else { // content that is not text uses the filesystem to store the data // (when sharing with a new local app) File dataLoc = storeData(message); if (mimeType.startsWith("image/")) { String path = Images.Media.insertImage(context.getContentResolver(), dataLoc.getPath(), message.getTitle(), null); Uri imageUri = Uri.parse(path); i.putExtra(Intent.EXTRA_STREAM, imageUri); // we can delete the temporary location in this case, since the file has been saved // to the media store. // In the other cases, the receiver has to handle the content of the temp file before // it can be deleted -- but we will never know if/when that happens. dataLoc.delete(); } else if (mimeType.equals(Constants.MIME_TYPE_TEXT_NOTE)) { String json = new String(message.getData()); try { JSONObject note = new JSONObject(json); i.putExtra(Intent.EXTRA_TEXT, note.getString(Intent.EXTRA_TEXT)); i.putExtra(Intent.EXTRA_SUBJECT, note.getString(Intent.EXTRA_SUBJECT)); i.setType("text/plain"); } catch (JSONException e) { e.printStackTrace(); } } else { i.putExtra(Intent.EXTRA_STREAM, dataLoc.toURI()); } } return i; }
From source file:com.gelecekonline.android.uploadornek.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); selectedImageView = (ImageView) findViewById(R.id.selectedImageView); selectImageButton = (Button) findViewById(R.id.selectImageButton); selectImageButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { try { //Resim secen Intent tanimlamasi Intent intent = new Intent(); intent.setType("image/*"); intent.setAction(Intent.ACTION_GET_CONTENT); startActivityForResult(Intent.createChooser(intent, getString(R.string.select_image)), SELECT_IMAGE_INTENT_ID); } catch (Exception e) { Toast.makeText(getApplicationContext(), getString(R.string.select_image_problem), Toast.LENGTH_LONG).show(); }//from w w w . j a v a 2 s.com } }); uploadButton = (Button) findViewById(R.id.uploadButton); uploadButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { if (selectedImageView.getDrawable() == null) { Toast.makeText(getApplicationContext(), getString(R.string.please_select_image), Toast.LENGTH_LONG).show(); } else { dialog = ProgressDialog.show(MainActivity.this, getString(R.string.image_uploading), getString(R.string.please_wait), true); if (uploadImageTask == null || uploadImageTask.getStatus() == AsyncTask.Status.FINISHED) { uploadImageTask = new UploadImageTask(); } uploadImageTask.execute(); } } }); }
From source file:com.daon.identityx.samplefidoapp.SplashActivity.java
/*** * Attempt to get the list of UAF Clients on the device and * add these to the static list./* ww w .j a va 2 s .c o m*/ * */ protected void loadUafClientList() { List<ResolveInfo> clientList; final Intent intent = new Intent(); intent.setAction(AndroidClientIntentParameters.intentAction); intent.setType(AndroidClientIntentParameters.intentType); PackageManager manager = this.getPackageManager(); clientList = manager.queryIntentActivities(intent, 0); UafClientLogUtils.logUafClientActivities(clientList); getUafClientList().addAll(clientList); }
From source file:org.peterbaldwin.client.android.tinyurl.SendTinyUrlActivity.java
private void send() { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); Intent originalIntent = getIntent(); if (Intent.ACTION_SEND.equals(originalIntent.getAction())) { // Copy extras from the original intent because they might contain // additional information about the URL (e.g., the title of a // YouTube video). Do this before setting Intent.EXTRA_TEXT to avoid // overwriting the TinyURL. intent.putExtras(originalIntent.getExtras()); }/*from ww w . j a v a2 s . c o m*/ intent.putExtra(Intent.EXTRA_TEXT, mTinyUrl); try { CharSequence template = getText(R.string.title_send); String title = String.format(String.valueOf(template), mTinyUrl); startActivity(Intent.createChooser(intent, title)); finish(); } catch (ActivityNotFoundException e) { handleError(e); } }