参考 http://m.blog.csdn.net/article/details?id=49177555
//分享至qq
public static void shareToQQ(String text){
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, text);
sendIntent.setType("text/plain");
sendIntent.setPackage("com.tencent.mobileqq");
sendIntent.setClassName("com.tencent.mobileqq", "com.tencent.mobileqq.activity.JumpActivity");
try{
sContext.startActivity(sendIntent);
}catch (Exception e){
e.printStackTrace();
ToastUtils.getInstance().showToast("未安装QQ,或QQ版本过低!");
}
}
//分享至微信
public static void shareToWx(String text) {
Intent intent = new Intent();
intent.setClassName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareImgUI");
intent.setAction("android.intent.action.SEND"); intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, text);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
sContext.startActivity(intent);
}catch (Exception e){
e.printStackTrace();
LogUtil.e(e.toString());
ToastUtils.getInstance().showToast("未安装微信,或微信版本过低!");
}
}