android调用系统的分享接口
16lz
2022-06-13
public void shareMsg(String activityTitle, String msgTitle, String msgText,
String imgPath) {
Intent intent = new Intent(Intent.ACTION_SEND);
if (imgPath == null || imgPath.equals("")) {
intent.setType("text/plain"); // 纯文本
} else {
File f = new File(imgPath);
if (f != null && f.exists() && f.isFile()) {
intent.setType("image/png");
Uri u = Uri.fromFile(f);
intent.putExtra(Intent.EXTRA_STREAM, u);
}
}
intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle);
intent.putExtra(Intent.EXTRA_TEXT, msgText);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(Intent.createChooser(intent, activityTitle));
}
String imgPath) {
Intent intent = new Intent(Intent.ACTION_SEND);
if (imgPath == null || imgPath.equals("")) {
intent.setType("text/plain"); // 纯文本
} else {
File f = new File(imgPath);
if (f != null && f.exists() && f.isFile()) {
intent.setType("image/png");
Uri u = Uri.fromFile(f);
intent.putExtra(Intent.EXTRA_STREAM, u);
}
}
intent.putExtra(Intent.EXTRA_SUBJECT, msgTitle);
intent.putExtra(Intent.EXTRA_TEXT, msgText);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(Intent.createChooser(intent, activityTitle));
}
更多相关文章
- Android(安卓)TextView Justify Text TextView自适应文本
- Android(安卓)Jetpack Compose 之 Text
- Android(安卓)图文混排spannableStringBuilder简单使用
- Android统计EditText的字母数字以及汉字的统计方法
- android 的文本框输入类型
- android 开源 OCR 项目 及手写识别[转]
- EditText 的常用属性与解释
- [android]控件EditText常用属性
- EditText属性