QQ分享功能实现-Android

这篇主要介绍实现QQ的分享图片功能,这里用QQ官方提供的SDK。QQ的分享功能直接使用,不需要授权软件,所以比较方便。

一、准备工作

1、创建应用

腾讯QQ互联官网进行注册登录,并且创建应用管理,,获取到你的APP ID和APP Key。这里我已经完成了

2、集成SDK

QQ互联的官方文档下载SDK,并将jar包导入项目中,这里我已经导入完成了。按照官方文档的步骤一步一步的完成。
在这里插入图片描述

二、代码

1、将open-sdk.jar加入编译路径

在app目录下的build.gradle中添加

dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
}

然后重新导入一下,这样open-sdk就会导入进来了。

2、配置AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


 <activity
            android:name="com.tencent.tauth.AuthActivity"
            android:launchMode="singleTask"
            android:noHistory="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.BROWSABLE" />

                <data android:scheme="tencent+你的id" />
            </intent-filter>
        </activity>
        <activity
            android:name="com.tencent.connect.common.AssistActivity"
            android:configChanges="orientation|keyboardHidden"
            android:screenOrientation="behind"
            android:theme="@android:style/Theme.Translucent.NoTitleBar" />

注意 "tencent+你的id"这个地方:如果你的id是123456,那么android:scheme:这个地方你要写成tencent123456。

3、布局文件activity_avatarupload.xml

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/scrollView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <Button
            android:id="@+id/share"
            
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值