第一种方法:特点--简单
在xml中添加权限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<span style="white-space:pre"> </span>Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/*");
<span style="white-space:pre"> </span>//intent.setType("text/plain");//纯文本
Bitmap bitmap = generateSpringCard();
Uri uri = Uri.parse(MediaStore.Images.Media.insertImage(getContentResolver(), bitmap, null,null));
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(intent);
* 获取当前屏幕截图
* @return
*/
private Bitmap generateSpringCard() {
View view = getWindow().getDecorView();
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
return view.getDrawingCache();
}
第二种方法: shareSDK
详见shareSDK