Android截屏分享
来源:互联网 发布:c语言定义函数并调用 编辑:程序博客网 时间:2024/05/17 02:19
Android截屏并进行分享应该是一个比较好用的功能,可惜在应用中见的不多
1. 截屏
/**
* 准备截屏
*/
public void prepareshoot(){
try{
boolean sdCardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);
if (sdCardExist) {
String rootPath = Environment.getExternalStorageDirectory().getPath()+"/colorgo";
File imgDir = new File(rootPath);
if (!imgDir.exists()) {
Log.v(tag, "logDir.mkdirs()");
imgDir.mkdirs();
}
imgpath = rootPath;
if(imgpathFile.equals(imgpath + "/colorgoShareImga.png")){
imgpathFile = imgpath + "/colorgoShareImgb.png";
}else{
imgpathFile = imgpath + "/colorgoShareImga.png";
}
}else{
Toast.makeText(context, " 存储卡未启用,暂时不能使用该功能。 ", Toast.LENGTH_LONG).show();
}
}catch (Exception ex){
Log.v(tag, "prepareshoot:"+ex.getMessage());
}
}
2. 分享,此处的分享仅仅是简单分享,如果要分享到微信等需要二次开发的平台,还需要一系列的操作,比较麻烦
/**
* 运行分享
*/
public void nativeShare(String content)
{
try{
Intent shareIt = new Intent("android.intent.action.SEND");
shareIt.setType("image/png");
shareIt.putExtra(Intent.EXTRA_SUBJECT, Constants.appname);
shareIt.putExtra(Intent.EXTRA_TEXT, content);
//分享sd卡的图片
shareIt.putExtra(Intent.EXTRA_STREAM,Uri.parse(imgpathFile));
shareIt.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(Intent.createChooser(shareIt, Constants.appname));
}catch (Exception ex){
Log.v(tag, "nativeShare:"+ex.getMessage());
}
}
3. 应用场景:经文分享:
比如三字经【http://zhushou.360.cn/detail/index/soft_id/1902511】小应用就是用了截屏分享,经文用于劝人劝己。
- Android截屏分享
- Android截屏分享
- Android截屏分享
- iOS Android 截屏分享图片,&& iOS自定义图片分享
- android 屏幕截屏源码分享
- cocos2dx Android游戏截屏分享
- android 截屏及分享代码示例
- 快速添加简单的Android截屏分享
- 【小超_U3D】Unity截屏分享调用Android
- Android 获取浏览器当前分享页面的截屏
- Android 获取浏览器当前分享页面的截屏
- Android 获取浏览器当前分享页面的截屏
- Android 获取浏览器当前分享页面的截屏
- Android 获取浏览器当前分享页面的截屏
- Android 获取浏览器当前分享页面的截屏
- Android 获取浏览器当前分享页面的截屏
- Android截屏分享工具类,默认截取当前页面
- Android截屏与WebView长图分享经验总结
- Cron表达式详解
- java--面向对象(final,Math,String)
- Binary Tree Postorder Traversal
- PHP设计模式——单例模式
- 顶级风投First Round Capital对创业者的30个建议
- Android截屏分享
- 用Android-X86和VirtualBox打造高性能Android开发环境
- IsPostBack结论
- 设计模式-builder(构造器模式)
- 西门子PLC学习笔记十七-(不带参数FC编程二)
- iOS UIImageView设置多张图片
- qsort函数使用方法
- c++与oc混编
- 译文 日经春秋 20150119