友盟第三方分享步骤
第一步 友盟集成工具
第二步 在umeng_android_social_sdk_6.4.5_custom\ umeng_integratetool_result\ libs下找到SDK 并且拷貝到Project 項目下的libs下 ?(生成)
? ? ? ? ?umeng_android_social_sdk_6.4.5_custom\umeng_integratetool_result\ ?res 下所有文件拷貝到Android項目下res目錄下
第三步 ?添加權限
? ? ? ? ? ? ? ? ? ? ?在Manifest中添加權限
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
? ? <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
? ? <uses-permission android:name="android.permission.READ_PHONE_STATE" />
? ? <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
? ? <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
? ? <uses-permission android:name="android.permission.INTERNET" />
? ? <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
? ? <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
? ? <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
第四步: 添加所需要的Activity;(精簡版與完成版的 在開始友盟集成工具中自己設置的那一個)
? ? ?sdk中需要的Activity
新浪:
? ?<activity
? ? ? ? ? ? android:name="com.umeng.socialize.media.WBShareCallBackActivity"
? ? ? ? ? ? android:configChanges="keyboardHidden|orientation"
? ? ? ? ? ? android:theme="@android:style/Theme.Translucent.NoTitleBar"
? ? ? ? ? ? android:exported="false"
? ? ? ? ? ? android:screenOrientation="portrait" >
? ? ? ? </activity>
?<activity android:name="com.sina.weibo.sdk.web.WeiboSdkWebActivity"
? ? ? ? ? ? ? ? ? android:configChanges="keyboardHidden|orientation"
? ? ? ? ? ? ? ? ? android:exported="false"
? ? ? ? ? ? ? ? ? android:windowSoftInputMode="adjustResize">
? ? ? ? </activity>
? ? ? ? <activity
? ? ? ? ? ? android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen"
? ? ? ? ? ? android:launchMode="singleTask"
? ? ? ? ? ? android:name="com.sina.weibo.sdk.share.WbShareTransActivity">
? ? ? ? ? ? <intent-filter>
? ? ? ? ? ? ? ? <action android:name="com.sina.weibo.sdk.action.ACTION_SDK_REQ_ACTIVITY" />
? ? ? ? ? ? ? ? <category android:name="android.intent.category.DEFAULT" />
? ? ? ? ? ? </intent-filter>
? ? ? ? </activity>
微信:
支付寶:
? ? <activity
? ? ? ? android:name=".apshare.ShareEntryActivity"
? ? ? ? android:configChanges="keyboardHidden|orientation|screenSize"
? ? ? ? android:exported="true"
? ? ? ? android:screenOrientation="portrait"
? ? ? ? android:theme="@android:style/Theme.Translucent.NoTitleBar" />
釘釘:
<activity
? ? android:name=".ddshare.DingCallBack"
? ? android:configChanges="keyboardHidden|orientation|screenSize"
? ? android:exported="true"
? ? android:screenOrientation="portrait"
? ? android:theme="@android:style/Theme.Translucent.NoTitleBar" /> ? ? ?
qq精簡版:
? ? <activity
? ? ? ? ? ? android:name="com.umeng.qq.tencent.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="tencent100424468" />
? ? ? ? ? ? </intent-filter>
? ? </activity>
? ? <activity
? ? ? ? ? ? android:name="com.umeng.qq.tencent.AssistActivity"
? ? ? ? ? ? android:screenOrientation="portrait"
? ? ? ? ? ? android:theme="@android:style/Theme.Translucent.NoTitleBar"
? ? ? ? ? ? android:configChanges="orientation|keyboardHidden|screenSize"/>
qq完整版:
? ? <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="tencent100424468" />
? ? ? ? ? ? </intent-filter>
? ? </activity>
? ? <activity
? ? ? ? ? ? android:name="com.tencent.connect.common.AssistActivity"
? ? ? ? ? ? android:screenOrientation="portrait"
? ? ? ? ? ? android:theme="@android:style/Theme.Translucent.NoTitleBar"
? ? ? ? ? ? android:configChanges="orientation|keyboardHidden|screenSize"/>
第五步: 添加友盟appkey (也在manifest里面的<application ?里面配置</application> )
? ? <meta-data
? ? ? ? ? ? android:name="UMENG_APPKEY"
? ? ? ? ? ? android:value="561cae6ae0f55abd990035bf" >
? ? </meta-data>
第六步 :http://www.umeng.com/ 友盟首頁注冊信息 注冊完成 找到 互聯網數據服務 中 ?U-Share 分享 進去后點擊 立即使用 ?后找到我的產品 添加新應用 添加完成之后 提交并獲取AppKey
? ? ? ? ? ? 獲得 Android 唯一Appkey為: 一長串字符 ?復制粘貼到 第五步 添加友盟AppKey ?將Value中的長串字符替換掉?
一個項目一個Key值 一個Module中只能創建一個項目 切記不要創建第二個?
第七步 創建一個類 APP ?繼承 Application{
? ? //底下的放置里面 ?微信的 QQ的 ?
? ? {
? ? ? ? PlatformConfig.setWeixin("wx967daebe835fbeac", "5bb696d9ccd75a38c8a0bfe0675559b3");
? ? ? ? PlatformConfig.setQQZone("100424468", "c7394704798a158208a74ab60104f0ba");
? ? ? ? PlatformConfig.setSinaWeibo("3921700954", "04b48b094faeb16683c32669824ebdad", "http://sns.whalecloud.com");
? ? }
//對sdk進行初始化 ?開啟DEBUG模式
? ? @Override
? ? public void onCreate() {
? ? ? ? super.onCreate();
? ? ? ? UMShareAPI.get(this);
//導包導import com.umeng.socialize.Config;
? ? ? ? Config.DEBUG = true;
? ? }
}
然后再<application 中 ?一定要最頂部/第一行添加 你創建那個類的名稱 android:name=".類名"
? ? ? ?復制DEBUG模式 ? 在umeng_android_social_sdk_6.4.5_custom文件下debug.keystore ?值接拷貝到Project下APP里面
第八步:
簽名配置
1、復制debug.keystore到model下
2、在build.grandle中添加:
buildTypes {
? ? ? ? release {
? ? ? ? ? ? minifyEnabled false
? ? ? ? ? ? signingConfig signingConfigs.debug
? ? ? ? ? ? proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
? ? ? ? }
? ? ? ? debug {
? ? ? ? ? ? minifyEnabled false
? ? ? ? ? ? signingConfig signingConfigs.debug
? ? ? ? ? ? proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
? ? ? ? }
? ? }
? ? signingConfigs {
? ? ? ? debug {
? ? ? ? ? ? storeFile file('debug.keystore')
? ? ? ? ? ? storePassword "android"
? ? ? ? ? ? keyAlias "androiddebugkey"
? ? ? ? ? ? keyPassword "android"
? ? ? ? }
? ? }
第九步 ?代碼混淆
-dontshrink
-dontoptimize
-dontwarn com.google.android.maps.**
-dontwarn android.webkit.WebView
-dontwarn com.umeng.**
-dontwarn com.tencent.weibo.sdk.**
-dontwarn com.facebook.**
-keep public class javax.**
-keep public class android.webkit.**
-dontwarn android.support.v4.**
-keep enum com.facebook.**
-keepattributes Exceptions,InnerClasses,Signature
-keepattributes *Annotation*
-keepattributes SourceFile,LineNumberTable
-keep public interface com.facebook.**
-keep public interface com.tencent.**
-keep public interface com.umeng.socialize.**
-keep public interface com.umeng.socialize.sensor.**
-keep public interface com.umeng.scrshot.**
-keep public class com.umeng.socialize.* {*;}
-keep class com.facebook.**
-keep class com.facebook.** { *; }
-keep class com.umeng.scrshot.**
-keep public class com.tencent.** {*;}
-keep class com.umeng.socialize.sensor.**
-keep class com.umeng.socialize.handler.**
-keep class com.umeng.socialize.handler.*
-keep class com.umeng.weixin.handler.**
-keep class com.umeng.weixin.handler.*
-keep class com.umeng.qq.handler.**
-keep class com.umeng.qq.handler.*
-keep class UMMoreHandler{*;}
-keep class com.tencent.mm.sdk.modelmsg.WXMediaMessage {*;}
-keep class com.tencent.mm.sdk.modelmsg.** implements com.tencent.mm.sdk.modelmsg.WXMediaMessage$IMediaObject {*;}
-keep class im.yixin.sdk.api.YXMessage {*;}
-keep class im.yixin.sdk.api.** implements im.yixin.sdk.api.YXMessage$YXMessageData{*;}
-keep class com.tencent.mm.sdk.** {
? ?*;
}
-keep class com.tencent.mm.opensdk.** {
? ?*;
}
-keep class com.tencent.wxop.** {
? ?*;
}
-keep class com.tencent.mm.sdk.** {
? ?*;
}
-dontwarn twitter4j.**
-keep class twitter4j.** { *; }
-keep class com.tencent.** {*;}
-dontwarn com.tencent.**
-keep class com.kakao.** {*;}
-dontwarn com.kakao.**
-keep public class com.umeng.com.umeng.soexample.R$*{
? ? public static final int *;
}
-keep public class com.linkedin.android.mobilesdk.R$*{
? ? public static final int *;
}
-keepclassmembers enum * {
? ? public static **[] values();
? ? public static ** valueOf(java.lang.String);
}
-keep class com.tencent.open.TDialog$*
-keep class com.tencent.open.TDialog$* {*;}
-keep class com.tencent.open.PKDialog
-keep class com.tencent.open.PKDialog {*;}
-keep class com.tencent.open.PKDialog$*
-keep class com.tencent.open.PKDialog$* {*;}
-keep class com.umeng.socialize.impl.ImageImpl {*;}
-keep class com.sina.** {*;}
-dontwarn com.sina.**
-keep class ?com.alipay.share.sdk.** {
? ?*;
}
-keepnames class * implements android.os.Parcelable {
? ? public static final ** CREATOR;
}
-keep class com.linkedin.** { *; }
-keep class com.android.dingtalk.share.ddsharemodule.** { *; }
-keepattributes Signature
第十步:
? 在點擊事件中 設置分享帶面板或不帶面板 和 下面的 UMImage image = new UMImage ?選擇本地文件?
?分享(帶面板)
new ShareAction(MainActivity.this)
? ? .withText("hello") ?
? ? .withMedia(image)
? ? .setDisplayList(SHARE_MEDIA.SINA,SHARE_MEDIA.QQ,SHARE_MEDIA.WEIXIN)
? ? .setCallback(new UMShareListener)
? ? .open();
關于分享面板的更多功能可以參照分享面板進階。
? ?分享(不帶面板)
new ShareAction(MainActivity.this)
.setPlatform(SHARE_MEDIA.QQ)//傳入平臺
.withText("hello")//分享內容
.setCallback(new UMShareListener )//回調監聽器
.share();
UMImage image = new UMImage(ShareActivity.this, "imageurl");//網絡圖片
UMImage image = new UMImage(ShareActivity.this, file);//本地文件 參數二:R.mipmap.ic_launcher
UMImage image = new UMImage(ShareActivity.this, R.drawable.xxx);//資源文件
UMImage image = new UMImage(ShareActivity.this, bitmap);//bitmap文件
UMImage image = new UMImage(ShareActivity.this, byte[]);//字節流
總結
- 上一篇: 单机dnf正在连接服务器,dnf提示正在
- 下一篇: DSO windowed optimiz