Android快速分享文件/文字到QQ/微信

一般来说,要想分享文件/文字到微信朋友圈、QQ,都是需要接入微信、QQ的分享sdk;不过也有个快速分享到QQ、微信的小窍门,就是通过action 为“android.intent.action.SEND”的Intent。
Talk is cheap. Show me the code.

1、先看看手Q的AndroidManifest.xml,我们可以看到可以接受“android.intent.action.SEND”的Intent,mimeType可以是图片("image/*")视频(“video/*”)音频("audio/*")文本("text/*")各种二进制文件("application/*")

<activity android:configChanges="keyboardHidden|locale|orientation" android:icon="@drawable/name_APKTOOL_DUPLICATENAME_0x7f021750" android:name="cooperation.qlink.QlinkShareJumpActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent">
   <intent-filter android:label="@string/name_APKTOOL_DUPLICATENAME_0x7f0c1126">
       <action android:name="android.intent.action.SEND"/>
       <category android:name="android.intent.category.DEFAULT"/>
       <data android:mimeType="image/*"/>
       <data android:mimeType="video/*"/>
       <data android:mimeType="audio/*"/>
       <data android:mimeType="application/*"/>
   </intent-filter>
   <intent-filter android:label="@string/name_APKTOOL_DUPLICATENAME_0x7f0c1126">
       <action android:name="android.intent.action.SEND_MULTIPLE"/>
       <category android:name="android.intent.category.DEFAULT"/>
       <data android:mimeType="image/*"/>
       <data android:mimeType="video/*"/>
       <data android:mimeType="audio/*"/>
       <data android:mimeType="application/*"/>
   </intent-filter>
</activity>
<activity android:configChanges="keyboardHidden|locale|orientation" android:exported="true" android:icon="@drawable/name_APKTOOL_DUPLICATENAME_0x7f02153d" android:name=".activity.qfileJumpActivity" android:theme="@android:style/Theme.Translucent">
    <intent-filter android:label="@string/name_APKTOOL_DUPLICATENAME_0x7f0c00fe">
        <action android:name="android.intent.action.SEND"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="image/*"/>
        <data android:mimeType="video/*"/>
        <data android:mimeType="audio/*"/>
        <data android:mimeType="application/*"/>
        <data android:mimeType="text/*"/>
    </intent-filter>
    <intent-filter android:label="@string/name_APKTOOL_DUPLICATENAME_0x7f0c00fe">
         <action android:name="android.intent.action.SEND_MULTIPLE"/>
         <category android:name="android.intent.category.DEFAULT"/>
         <data android:mimeType="image/*"/>
     </intent-filter>
 </activity>

2、再来看看微信的AndroidManifest.xml, 我们也可以看到有Activity接受action为“android.intent.action.SEND”的Intent,接受的mimeType类型同上

<activity android:configChanges="keyboardHidden|orientation|screenSize" android:icon="@drawable/icon" android:name="com.tencent.mm.ui.tools.ShareImgUI" android:theme="@style/ab">
     <intent-filter android:label="@string/v1">
         <action android:name="android.intent.action.SEND"/>
         <category android:name="android.intent.category.DEFAULT"/>
         <data android:mimeType="image/*"/>
         <data android:mimeType="video/*"/>
         <data android:mimeType="text/*"/>
         <data android:mimeType="application/*"/>
     </intent-filter>
     <intent-filter android:label="@string/v1">
         <action android:name="android.intent.action.SEND_MULTIPLE"/>
         <category android:name="android.intent.category.DEFAULT"/>
         <data android:mimeType="image/*"/>
     </intent-filter>
</activity>
<activity android:configChanges="keyboardHidden|orientation|screenSize" android:icon="@drawable/b1f" android:name="com.tencent.mm.ui.tools.AddFavoriteUI" android:theme="@style/ab">
    <intent-filter android:label="@string/gb">
          <action android:name="android.intent.action.SEND"/>
          <category android:name="android.intent.category.DEFAULT"/>
          <data android:mimeType="image/*"/>
          <data android:mimeType="video/*"/>
          <data android:mimeType="text/*"/>
          <data android:mimeType="application/*"/>
          <data android:mimeType="audio/*"/>
    </intent-filter>
    <intent-filter android:label="@string/gb">
         <action android:name="android.intent.action.SEND_MULTIPLE"/>
         <category android:name="android.intent.category.DEFAULT"/>
         <data android:mimeType="image/*"/>
     </intent-filter>
</activity>

3、那么,我们想要分享文件到微信/QQ/邮件就可以设置代码如下:

Intent intent = new Intent(Intent.ACTION_SEND, Uri.parse("mailto:"));
intent.putExtra(Intent.EXTRA_SUBJECT," 图片分享" );
// 兼容android 7.0+
Uri uri = FileProvider.getUriForFile(
          getContext(),
          getContext().getPackageName(),
          barcodeFile);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("image/*");
startActivity(intent);

4、看看效果,完美:

在这里插入图片描述

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
### 回答1: 有很多网站、应用、微信公众号和QQ号码都提供了20000个头像集合打包下载的服务。这些头像涵盖了各种风格和主题,包括卡通、明星、动物、自然风景、艺术等。用户可以根据自己的需求选择合适的头像进行下载和使用。 这些头像集合下载服务的目的是为了方便用户在社交平台上更换个人头像,增加个人形象的个性化和多样性。无论是网站、应用、微信还是QQ,用户只需要在相应的平台上搜索关键词,如"20000个头像集合下载",就可以找到相关的资源。一旦找到合适的资源,用户可以选择打包下载整个集合,也可以选择单个头像进行下载。 对于用户来说,这种头像集合下载服务的好处是多样的。首先,他们可以从海量的头像中选择最符合自己的个人风格和兴趣的头像。其次,这些头像集合往往包含了各种主题的头像,用户可以根据自己需求进行选择和下载。第三,这些头像通常是高清的,可以保证在不同平台上的清晰显示效果。第四,这种下载服务一般是免费的,用户可以随时随地下载并使用这些头像。 总的来说,20000个头像集合打包下载服务为用户提供了一个方便、多样化和个性化的选择。无论是网站、应用、微信还是QQ,用户都可以通过搜索和下载这些头像集合来满足自己的社交平台个人头像需求。 ### 回答2: 有很多网站、应用和社交平台提供了20000个头像集合的打包下载服务。这些头像可以用于网站、应用程序、微信、社交媒体和QQ等平台的个人资料图片。这些头像集合通常包含了各种不同的风格和主题,如动漫人物、明星、自然风景、抽象艺术等等,可以满足用户的不同需求和个性。用户可以通过登录相关平台并搜索头像集合,然后下载整个集合或选择自己喜欢的头像进行下载。这些平台通常提供不同的下载格式,如JPEG、PNG等。用户只需点击下载按钮,即可将头像保存到自己的设备中。用户可以根据自己的喜好和需求,将这些头像设置为个人资料照片,展示自己的个性和风格。同时,用户也可以将这些头像用于其他用途,如网站设计、应用程序开发等。总而言之,20000个头像集合打包下载服务为用户提供了便捷、丰富和多样化的头像选择,可以满足他们在不同平台中的个人形象展示需求。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值