List of usage examples for android.content Intent setDataAndType
public @NonNull Intent setDataAndType(@Nullable Uri data, @Nullable String type)
From source file:com.just.agentweb.AgentWebUtils.java
static void setIntentDataAndType(Context context, Intent intent, String type, File file, boolean writeAble) { if (Build.VERSION.SDK_INT >= 24) { intent.setDataAndType(getUriFromFile(context, file), type); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); if (writeAble) { intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); }//from w w w . j av a 2 s . c om } else { intent.setDataAndType(Uri.fromFile(file), type); } }
From source file:com.silentcircle.silenttext.util.DeviceUtils.java
public static Intent getShareDebugInformationIntent(Context context) { Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", context.getString(R.string.support_email_address), null)); intent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.support_email_subject)); intent.putExtra(Intent.EXTRA_TEXT, wrap(LABEL_DEBUG_INFO, getDebugInformation(context))); ResolveInfo info = context.getPackageManager().resolveActivity(intent, 0); if (info == null) { intent.setAction(Intent.ACTION_SEND); intent.setDataAndType(null, "text/plain"); }/*from w w w .j a v a 2s . c om*/ return Intent.createChooser(intent, context.getString(R.string.share_with, context.getString(R.string.feedback))); }
From source file:com.commonsware.android.foredown.DownloadFragment.java
@Override public void onClick(View v) { Intent i = new Intent(getActivity(), Downloader.class); i.setDataAndType(Uri.parse("https://commonsware.com/Android/Android-1_0-CC.pdf"), "application/pdf"); getActivity().startService(i);//from ww w . ja va 2 s. c o m getActivity().finish(); }
From source file:com.commonsware.android.okhttp3.progress.DownloadFragment.java
@Override public void onClick(View v) { Intent i = new Intent(getActivity(), Downloader.class); i.setDataAndType(Uri.parse("http://commonsware.com/Android/Android-1_1-CC.pdf"), "application/pdf"); getActivity().startService(i);//from w w w .jav a2s . c o m getActivity().finish(); }
From source file:edu.stanford.mobisocial.dungbeetle.obj.action.ViewFeedObjAction.java
@Override public void onAct(Context context, DbEntryHandler objType, DbObj obj) { JSONObject objData = obj.getJson();/*from w w w. j a v a 2s.co m*/ if (objData.has(DbObject.CHILD_FEED_NAME)) { Uri appFeed = Feed.uriForName(objData.optString(DbObject.CHILD_FEED_NAME)); Intent viewFeed = new Intent(Intent.ACTION_VIEW); viewFeed.setDataAndType(appFeed, Feed.MIME_TYPE); context.startActivity(viewFeed); } }
From source file:com.amaze.filemanager.utils.files.FileUtils.java
private static boolean isSelfDefault(File f, Context c) { Intent intent = new Intent(); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(f), MimeTypes.getMimeType(f.getPath(), f.isDirectory())); String s = ""; ResolveInfo rii = c.getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY); if (rii != null && rii.activityInfo != null) s = rii.activityInfo.packageName; return s.equals("com.amaze.filemanager") || rii == null; }
From source file:edu.stanford.mobisocial.dungbeetle.obj.action.RelatedObjAction.java
@Override public void onAct(Context context, DbEntryHandler objType, DbObj obj) { Uri feedUri = obj.getContainingFeed().getUri(); long hash = obj.getHash(); // TODO:/*from ww w.ja v a 2 s . c o m*/ /*Intent viewComments = new Intent(Intent.ACTION_VIEW); viewComments.setDataAndType(objUri, DbObject.MIME_TYPE); mmContext.startActivity(viewComments);*/ Uri objUri = feedUri.buildUpon().encodedPath(feedUri.getPath() + ":" + hash).build(); Intent objViewActivity = new Intent(Intent.ACTION_VIEW); objViewActivity.setDataAndType(objUri, Feed.MIME_TYPE); context.startActivity(objViewActivity); }
From source file:com.javielinux.dialogs.SelectImageDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { int title = getArguments().getInt("title"); idUser = getArguments().getLong("id_user"); file = getArguments().getString("file"); return new AlertDialog.Builder(getActivity()).setTitle(title) .setItems(R.array.select_type_image, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { if (which == 0) { File f = new File(file); if (f.exists()) f.delete();/* w ww .ja v a 2 s .c o m*/ Intent intendCapture = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); intendCapture.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(f)); intendCapture.putExtra("return-data", true); getActivity().startActivityForResult(intendCapture, ACTIVITY_CAMERA); } else if (which == 1) { Intent i = new Intent(Intent.ACTION_PICK); i.setDataAndType(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, MediaStore.Images.Media.CONTENT_TYPE); getActivity().startActivityForResult(i, ACTIVITY_SELECTIMAGE); } } }).create(); }
From source file:com.commonsware.android.camcon.CameraContentDemoActivity.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == CONTENT_REQUEST) { if (resultCode == RESULT_OK) { Intent i = new Intent(Intent.ACTION_VIEW); i.setDataAndType(outputUri, "image/jpeg"); i.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); startActivity(i);/*from w w w . j a v a 2 s . c om*/ finish(); } } }
From source file:com.example.util.Utils.java
/** * Android /*w ww . j a v a 2 s .c o m*/ * * @param context Application Context * @param filePath APK */ public static void installApk(Context context, File file) { if (file.exists()) { Intent i = new Intent(Intent.ACTION_VIEW); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); ((ContextWrapper) context).startActivity(i); } else { //makeEventToast(context, context.getString(R.string.install_fail_file_not_exist), false); } }