不多说直接上代码,同时感谢网上大牛些!!!
// 分享到朋友圈
private void shareWeixin() {
try {
Intent intent = new Intent();
ComponentName comp = new ComponentName("com.tencent.mm",
"com.tencent.mm.ui.tools.ShareToTimeLineUI");
intent.setComponent(comp);
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra("Kdescription", mContent);
// 传入图片
intent.putExtra(Intent.EXTRA_STREAM, mPhotoUri);
startActivity(intent);
} catch (Exception e) {
Toast.makeText(this, "请安装微信后再试", Toast.LENGTH_SHORT).show();
}
}
// 分享到微信好友
private void shareWeixin() {
try {
Intent intent = new Intent();
// 不设置 则选择分享位置
ComponentName comp = new ComponentName("com.tencent.mm",
"com.tencent.mm.ui.tools.ShareImgUI");
intent.setComponent(comp);
intent.setAction(Intent.ACTION_SEND);
intent.setType("image/*");
intent.putExtra("Kdescription", mContent);
// 传入图片
intent.putExtra(Intent.EXTRA_STREAM, mPhotoUri);
startActivity(intent);
} catch (Exception e) {
Toast.makeText(this, "请安装微信后再试", Toast.LENGTH_SHORT).show();
}
}