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));
}

更多相关文章

  1. Android(安卓)TextView Justify Text TextView自适应文本
  2. Android(安卓)Jetpack Compose 之 Text
  3. Android(安卓)图文混排spannableStringBuilder简单使用
  4. Android统计EditText的字母数字以及汉字的统计方法
  5. android 的文本框输入类型
  6. android 开源 OCR 项目 及手写识别[转]
  7. EditText 的常用属性与解释
  8. [android]控件EditText常用属性
  9. EditText属性

随机推荐

  1. Android:ActivityOptions
  2. 用TextView自定义按钮
  3. android p cts CtsCameraTestCases fail
  4. Android emulator
  5. js检测手机类型(android,ios,blackberry,w
  6. Android:圆形CheckBox
  7. Android WebView嵌套Html 之一
  8. android ant使用分析
  9. 【Android多媒体】多媒体架构-Android官
  10. Airbnb Android