android 系统的分享功能

  private void share(String content, Uri uri){
     Intent shareIntent = new Intent(Intent.ACTION_SEND); 
     if(uri!=null){
     //uri 是图片的地址
      shareIntent.putExtra(Intent.EXTRA_STREAM, uri);
      shareIntent.setType("image/*"); 
      //当用户选择短信时使用sms_body取得文字
      shareIntent.putExtra("sms_body", content);
     }else{
      shareIntent.setType("text/plain"); 
     }
     shareIntent.putExtra(Intent.EXTRA_TEXT, content);
     //自己定义选择框的标题
     //startActivity(Intent.createChooser(shareIntent, "邀请好友"));
     //系统默认标题
     startActivity(shareIntent);
    }

相关文章:

  • 2021-05-13
  • 2021-12-19
  • 2021-06-17
  • 2022-12-23
  • 2021-11-17
  • 2021-12-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-10-21
  • 2021-04-19
  • 2022-12-23
  • 2021-06-14
  • 2022-01-02
相关资源
相似解决方案