android调用本地分享

分享图片

public static void shareImage(Context context, Uri uri, String title) {

Intent shareIntent = new Intent();

shareIntent.setAction(Intent.ACTION_SEND);

shareIntent.putExtra(Intent.EXTRA_STREAM, uri);

shareIntent.setType("image/jpeg");

context.startActivity(Intent.createChooser(shareIntent, title));

 }

分享文字

public static void share(Context context, String extraText) {

Intent intent = new Intent(Intent.ACTION_SEND);

intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.action_share)); intent.putExtra(Intent.EXTRA_TEXT, extraText);

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

context.startActivity( Intent.createChooser(intent, context.getString(R.string.action_share)));

}

这样可以调用本地的分享,标签、微信什么的都可以。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容