List of usage examples for android.content Intent setDataAndType
public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type)
From source file:com.abc.driver.PersonalActivity.java
/** * start to choose pictue/*from w w w.j av a2 s . c o m*/ */ private void startToMediaActivity(int requestId) { Intent localIntent = new Intent("android.intent.action.PICK"); Uri localUri = MediaStore.Images.Media.INTERNAL_CONTENT_URI; localIntent.setDataAndType(localUri, "image/*"); startActivityForResult(localIntent, requestId); }
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;/*w w w .j a v a 2 s .co m*/ 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:com.google.sample.cast.refplayer.chatting.MainActivity.java
public void openScreenshot(File imageFile) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Uri uri = Uri.fromFile(imageFile);// w w w . ja va2 s. co m intent.setDataAndType(uri, "image/*"); startActivity(intent); }
From source file:com.java2s.intents4.IntentsDemo4Activity.java
private Intent createIntentFromEditTextFields() { String theAction = actionText.getText().toString().trim(); String theUri = uriText.getText().toString().trim(); String theMimeType = mimeTypeText.getText().toString().trim(); Intent intent = new Intent(); if (theAction.length() != 0) { intent.setAction(theAction);//from www .j a v a2 s.c o m } intentHasBothUriAndType = false; if (theUri.length() != 0 && theMimeType.length() != 0) { intentHasBothUriAndType = true; intent.setDataAndType(Uri.parse(theUri), theMimeType); } else if (theUri.length() != 0) { intent.setData(Uri.parse(theUri)); } else if (theMimeType.length() != 0) { intent.setType(theMimeType); } if (intentCategoriesLayout != null) { int count = intentCategoriesLayout.getChildCount(); for (int i = 0; i < count; i++) { String cat = ((EditText) ((ViewGroup) intentCategoriesLayout.getChildAt(i)).getChildAt(1)).getText() .toString().trim(); if (cat.length() != 0) { intent.addCategory(cat); } } } Log.i(CLASSNAME, intent.toString()); return intent; }
From source file:com.grass.caishi.cc.activity.AdAddActivity.java
/** * ?/*from w ww. j av a 2 s .com*/ * * @param uri * @param outputX * @param outputY * @param requestCode */ private void cropImageUri(Uri uri, int outputX, int outputY, int requestCode) { /* * Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); intent.putExtra("crop", "true"); //aspectX aspectY intent.putExtra("aspectX", 1); intent.putExtra("aspectY", 1); // outputX outputY ? intent.putExtra("outputX", outputX); intent.putExtra("outputY", outputY); intent.putExtra("scale", true); intent.putExtra(MediaStore.EXTRA_OUTPUT, uri); intent.putExtra("return-data", false); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); intent.putExtra("noFaceDetection", true); // no face detection startActivityForResult(intent, requestCode); */ Intent intent = new Intent("com.android.camera.action.CROP"); intent.setDataAndType(uri, "image/*"); intent.putExtra("crop", "true"); intent.putExtra("aspectX", 3); intent.putExtra("aspectY", 1); intent.putExtra("outputX", outputX); intent.putExtra("outputY", outputY); intent.putExtra("scale", true); intent.putExtra("return-data", true); intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); intent.putExtra("noFaceDetection", true); // no face detection startActivityForResult(intent, requestCode); }
From source file:edu.stanford.mobisocial.dungbeetle.NearbyActivity.java
@Override protected void onListItemClick(ListView l, View v, int position, long id) { NearbyItem g = mAdapter.getItem(position); if (g.type == NearbyItem.Type.PERSON) { long cid = FriendRequest.getExistingContactId(this, g.uri); if (cid != -1) { Contact.view(this, cid); } else {// ww w.j a v a 2 s . c om toast("Added new friend..."); cid = FriendRequest.acceptFriendRequest(mContext, g.uri, false); String cap = g.uri.getQueryParameter("cap"); FriendRequest.sendFriendRequest(mContext, cid, cap); Contact.view(this, cid); } return; } Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(g.uri, g.mimeType); intent.setPackage(getPackageName()); startActivity(intent); }
From source file:me.myatminsoe.myansms.Message.java
/** * Fetch MMS parts./*from w ww .j a v a2 s . c o m*/ * * @param context {@link Context} */ private void fetchMmsParts(final Context context) { final ContentResolver cr = context.getContentResolver(); Cursor cursor = cr.query(URI_PARTS, null, PROJECTION_PARTS[INDEX_MID] + " = ?", new String[] { String.valueOf(id) }, null); if (cursor == null || !cursor.moveToFirst()) { return; } final int iID = cursor.getColumnIndex(PROJECTION_PARTS[INDEX_ID]); final int iCT = cursor.getColumnIndex(PROJECTION_PARTS[INDEX_CT]); final int iText = cursor.getColumnIndex("text"); do { final int pid = cursor.getInt(iID); final String ct = cursor.getString(iCT); // get part InputStream is = null; final Uri uri = ContentUris.withAppendedId(URI_PARTS, pid); if (uri == null) { continue; } try { is = cr.openInputStream(uri); } catch (IOException | NullPointerException e) { } if (is == null) { if (iText >= 0 && ct != null && ct.startsWith("text/")) { body = cursor.getString(iText); } continue; } if (ct == null) { continue; } if (ct.startsWith("image/")) { picture = BitmapFactory.decodeStream(is); final Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(uri, ct); i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); contentIntent = i; continue; // skip the rest } else if (ct.startsWith("video/") || ct.startsWith("audio/")) { picture = BITMAP_PLAY; final Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(uri, ct); i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); contentIntent = i; continue; // skip the rest } else if (ct.startsWith("text/")) { body = fetchPart(is); } try { is.close(); } catch (IOException e) { } // Ignore } while (cursor.moveToNext()); }
From source file:cm.aptoide.pt.services.ServiceDownloadManager.java
public void installApp(ViewCache apk, boolean isObb) { // if(isAppScheduledToInstall(appHashid)){ // unscheduleInstallApp(appHashid); // }// w w w . j a v a2s. c o m ViewCache thisCache; if (isObb) { thisCache = ((ViewCacheObb) apk).getParentCache(); } else { thisCache = apk; } Intent install = new Intent(Intent.ACTION_VIEW); install.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); install.setDataAndType(Uri.fromFile(thisCache.getFile()), "application/vnd.android.package-archive"); Log.d("Aptoide", "Installing app: " + thisCache.getLocalPath()); startActivity(install); }
From source file:com.abc.driver.TruckActivity.java
/** * start to choose pictue/*from w w w .j a v a 2s. c o m*/ */ private void startToMediaActivity(int actionId) { Intent localIntent = new Intent("android.intent.action.PICK"); Uri localUri = MediaStore.Images.Media.INTERNAL_CONTENT_URI; localIntent.setDataAndType(localUri, "image/*"); startActivityForResult(localIntent, actionId); }
From source file:cm.aptoide.pt.services.ServiceDownloadManager.java
private synchronized void setCompletedNotification(ViewDownloadManagement download) { managerNotification = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mBuilder = new NotificationCompat.Builder(this); Intent onClick = new Intent(Intent.ACTION_VIEW); onClick.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); onClick.setDataAndType(Uri.fromFile(download.getCache().getFile()), "application/vnd.android.package-archive"); // The PendingIntent to launch our activity if the user selects this notification PendingIntent onClickAction = PendingIntent.getActivity(this, 0, onClick, 0); mBuilder.setContentTitle(getString(R.string.finished_download, ApplicationAptoide.MARKETNAME)) .setContentText(download.getAppInfo().getName()); Bitmap bm = BitmapFactory.decodeFile(ImageLoader.getInstance().getDiscCache() .get(download.getAppInfo().getApkid() + "|" + download.getAppInfo().getVercode()) .getAbsolutePath());/*from www . jav a2 s . co m*/ mBuilder.setLargeIcon(bm); mBuilder.setSmallIcon(android.R.drawable.stat_sys_download_done); mBuilder.setContentIntent(onClickAction); mBuilder.setAutoCancel(true); managerNotification.notify(download.getAppInfo().getAppHashId(), mBuilder.build()); Log.d("Aptoide-Downloader", "Set Finished notification"); }