写道
public void shareText(Context context, String title, String text) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, title);
intent.putExtra(Intent.EXTRA_TEXT, text);
context.startActivity(Intent.createChooser(intent, title));
}
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, title);
intent.putExtra(Intent.EXTRA_TEXT, text);
context.startActivity(Intent.createChooser(intent, title));
}
本文介绍了一种使用Android平台的Intent机制来分享文本内容的方法。通过创建一个公共方法`shareText`,可以轻松地将指定的标题和文本内容分享到用户的其他应用程序中,如电子邮件客户端或社交媒体平台。
599

被折叠的 条评论
为什么被折叠?



