一、分享String
ShareCompat.IntentBuilder.from(this).setType("text/plain")
.setText("内容").startChooser();
二、分享文件
public void onShareFileClick(View v) {
try {
FileWriter fw = new FileWriter(getFilesDir() + "/foo.txt");
fw.write("This is a file share");
fw.close();
ShareCompat.IntentBuilder.from(this)
.setType("text/plain")
.setStream(Uri.parse(SharingSupportProvider.CONTENT_URI + "/foo.txt"))
.startChooser();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
具体请参考:http://www.cnblogs.com/outOfview/p/3643446.html
http://android.toolib.net/reference/android/support/v4/app/ShareCompat.IntentBuilder.html
原文地址:http://9437752.blog.51cto.com/9427752/1583133