Android 系统自带的社会化分享

分享到朋友圈

    /**
     * 分享信息到朋友圈
     */
    private void shareToFriendsQuan(String file) {
        Intent intent = new Intent();
        ComponentName componentName = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareToTimeLineUI");
        intent.setComponent(componentName);

        intent.setAction(Intent.ACTION_SEND);
//        intent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(this,"com.android.speech.fileProvider",file));
        intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(file));

        intent.setType("image/*");

        startActivity(intent);
    }

分享给好友

/**
     * 分享信息到朋友
     */
    private void shareToFriend(String file) {
        Intent intent = new Intent();
        ComponentName componentName = new ComponentName("com.tencent.mm", "com.tencent.mm.ui.tools.ShareImgUI");
        intent.setComponent(componentName);
        intent.setAction(Intent.ACTION_SEND);
        intent.setType("image/*");
        intent.putExtra(Intent.EXTRA_STREAM, Uri.parse(file));
        startActivity(intent);
    }

如果遇到 获取资源错误  参考 https://blog.csdn.net/vv_gool/article/details/53230504

猜你喜欢

转载自blog.csdn.net/wljian1/article/details/79804121