当前位置: 首页 > news >正文

手游网站源码下载高端网站设计工作室

手游网站源码下载,高端网站设计工作室,各大企业网站文案,韩国优秀电商网站什么是 Android 系统的原生分享呢#xff0c;如下图所示 创建一个 Intent #xff0c;指定其 Action 为 Intent.ACTION_SEND#xff0c;这表示要创建一个发送指定内容的行动。 Intent sendIntent new Intent(); sendIntent.setAction(Intent.ACTION_SEND); 指定需要发送的…什么是 Android 系统的原生分享呢如下图所示 创建一个 Intent 指定其 Action 为 Intent.ACTION_SEND这表示要创建一个发送指定内容的行动。 Intent sendIntent new Intent(); sendIntent.setAction(Intent.ACTION_SEND); 指定需要发送的内容和类型。 // 比如发送文本形式的数据内容 // 指定发送的内容 sendIntent.putExtra(Intent.EXTRA_TEXT, This is my text); // 指定发送内容的类型 sendIntent.setType(text/plain); // 比如发送二进制文件数据流内容比如图片、视频、音频文件等等 // 指定发送的内容 (EXTRA_STREAM 对于文件 Uri ) shareIntent.putExtra(Intent.EXTRA_STREAM, uri); // 指定发送内容的类型 (MIME type) shareIntent.setType(image/jpeg); 向系统发送Activity打开系统分享选择器出现如上图所示界面。  startActivity(Intent.createChooser(shareIntent, Share)); 完整代码如下 // 原生通用分享文本 public void shareText(String title, String text){Intent sendIntent new Intent();sendIntent.setAction(Intent.ACTION_SEND);if (title.isEmpty()){title share;}sendIntent.putExtra(Intent.EXTRA_TEXT, text);sendIntent.setType(text/plain);startActivityForResult(Intent.createChooser(sendIntent, title), 80001); }// 原生通用分享图片 public void shareImage(String title, String filePath){Intent sendIntent new Intent();sendIntent.setAction(Intent.ACTION_SEND);if (title.isEmpty()){title share;}File file new File(filePath);Uri uri getFileUri(this, file);sendIntent.putExtra(Intent.EXTRA_STREAM, uri);sendIntent.setType(image/png);startActivityForResult(Intent.createChooser(sendIntent, title), 80002); }public Uri getFileUri(Context context, File file){Uri uri;// 低版本直接用 Uri.fromFileif (Build.VERSION.SDK_INT Build.VERSION_CODES.N) {uri Uri.fromFile(file);}else {try {uri FileProvider.getUriForFile(this, getPackageName0() .fileProvider, file);} catch (Exception e) {e.printStackTrace();uri getImageContentUri(context, file);}if (uri null) {uri getImageContentUri(context, file);}}return uri; }public Uri getImageContentUri(Context context, File imageFile) {String filePath imageFile.getAbsolutePath();Cursor cursor context.getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,new String[] { MediaStore.Images.Media._ID }, MediaStore.Images.Media.DATA ? ,new String[] { filePath }, null);if (cursor ! null cursor.moveToFirst()) {int id cursor.getInt(cursor.getColumnIndex(MediaStore.MediaColumns._ID));Uri baseUri Uri.parse(content://media/external/images/media);return Uri.withAppendedPath(baseUri, id);} else {if (imageFile.exists()) {ContentValues values new ContentValues();values.put(MediaStore.Images.Media.DATA, filePath);return context.getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);} else {return null;}} }如果要分享到指定的app呢 // 特定App 分享文本 public void shareTextByApp(String pkgName, String appName, String title, String text){if (!checkAppInstalled(this, pkgName)){Toast.makeText(getApplicationContext(), You need install the appName first, Toast.LENGTH_LONG).show();return;}if (title.isEmpty()){title share;}Intent sendIntent new Intent();sendIntent.setAction(Intent.ACTION_SEND);sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);sendIntent.putExtra(Intent.EXTRA_TEXT, text);sendIntent.setType(text/plain);sendIntent.setPackage(pkgName);startActivity(sendIntent); }// 特定App 分享文本 public void shareImageByApp(String pkgName, String appName, String title, String filePath){if (!checkAppInstalled(this, pkgName)){Toast.makeText(getApplicationContext(), You need install the appName first, Toast.LENGTH_LONG).show();return;}if (title.isEmpty()){title share;}Intent sendIntent new Intent();sendIntent.setAction(Intent.ACTION_SEND);sendIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);File file new File(filePath);Uri uri getFileUri(this, file);sendIntent.putExtra(Intent.EXTRA_STREAM, uri);sendIntent.setType(image/png);sendIntent.setPackage(pkgName);startActivity(sendIntent); }// 是否安装某app public boolean checkAppInstalled(Context context, String pkgName) {try {context.getPackageManager().getPackageInfo(pkgName, 0);} catch (Exception x) {return false;}return true; } //例如 WhatsApp 的分享 shareTextByApp(com.whatsapp, WhatsApp, title, content);//Facebook 的分享 shareImageByApp(com.facebook.katana, Facebook, title, filePath);
http://www.dnsts.com.cn/news/116287.html

相关文章:

  • 长春朝阳网站建设注册有限公司需要什么条件
  • 网站程序上传工具wordpress搜索返回页面内容
  • 嘉兴做网站建设租用服务器
  • 网站可不可以做自己的专利做电脑系统的网站
  • 网站 keywords seo沈阳制作网站
  • 给你网站你会怎么做软件开发app制作
  • 建设一个官方网站的费用网站html模板
  • 做dnf辅助网站十大计算机培训机构排名
  • 做网站 接单深圳小程序app开发
  • 云南公司建网站多少钱大学学校网站建设方案
  • 哪个网站专做进口商品的wordpress 迅影网
  • 黄村网站开发公司实时新闻最新消息
  • strikingly建站工具wordpress网站有多大
  • 开发手机端网站模板绥德网站建设设计
  • 网站重定向代码湖北什么网站建设值得推荐
  • 做网站赚钱么wordpress创意插件
  • 客户评价网站建设施工企业岗前培训内容记录
  • 做网站标签栏的图片大小记事本怎么做网页
  • 做故障风的头像的网站学做网站看什么书
  • 网站建设类织梦模板衡水企业网站建设公司
  • 网站建设优化服务多少钱优书网
  • 营销型单页网站应用公园免费版下载
  • 网站添加视频代码电商网站开发脑图
  • 便利店网站建设拓扑图互联网网站排名
  • iis7如何设置ip做网站做外汇应该看哪一家网站
  • 网站设计方案策划吃的网站要怎么做
  • 网站建设公司客户开发手册迁移wordpress500错误
  • 易语言怎么做ifa网站填表饰品做国际贸易哪些网站
  • 外国网站上做雅思考试WordPress自动拼音别名
  • 望城门户网站网上交易网