---
title: "android 分享到微博"
author: "zheyiw"
date: "2012-10-10T13:36:26Z"
tags: ["Android"]
categories: ["移动开发"]
slug: "android"
draft: false
lastmod: "2012-10-10T13:36:26Z"
id: 1695018
url: "https://zheyiw.iteye.com/blog/1695018"
---

```java


	/**
	 * 分享到微博等
	 */
	void share() {
		Intent intent = new Intent(Intent.ACTION_SEND);
		intent.setType("text/plain"); // 纯文本
		/*图片分享
		it.setType("image/png");
		//添加图片
		File f = new File(Environment.getExternalStorageDirectory() +"/Pictures/2.png");
		Uri u = Uri.fromFile(f);
		it.putExtra(Intent.EXTRA_STREAM, u);
		*/
		StringBuffer sb = new StringBuffer();
		sb.append(getStr(R.string.company_short)).append(
				getStr(R.string.des_share_1));
		sb.append("\"").append(Comm.currentProduct.title).append("\"");
		sb.append(getStr(R.string.des_share_2)).append(" ")
				.append(Comm.pWeb_homeURL);
		sb.append(Comm.pWeb_ProductDetail).append(Comm.currentProduct.value);
		intent.putExtra(Intent.EXTRA_SUBJECT, "");
		intent.putExtra(Intent.EXTRA_TEXT, sb.toString());
		startActivity(Intent.createChooser(intent, getTitle()));
	}


```