ShareSDK Android接入cocos2d-X lua
来源:互联网 发布:喜马拉雅fm无网络连接 编辑:程序博客网 时间:2024/06/05 07:50
1. 安装jdk 配置环境
JAVA_HOME jdk目录
Path %JAVA_HOME%\bin;%JAVA_HOME%\jre\bin;
classPath .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\tools.jar
2.安装eclipse(解压)
3.sdk安装 、ndk安装(解压就好)
4.adt下载
5.配置adt
打开eclipse ->点击Help ->Install New SoftWare -> add
name(随便起) 路径选择adt压缩包安装、软件重启
6.配置sdk、ndk
打开eclipse ->点击Window->Preferences->Android-> 配置SDK
打开eclipse ->点击Window->Preferences->Android-> 子目录NDK ->配置NDK
7.下载ShareSDK(要和项目放在同一盘符下)
8.在eclipse中导入项目、导入ShareSDK(默认就是库的形式)(可以删除不必要的平台)
9.在自己的项目中导入ShareSDK
10.配置AndroidManifest.xml权限文件
1.添加权限(重复的删除)
<uses-permissionandroid:name="android.permission.GET_TASKS" /> <uses-permissionandroid:name="android.permission.INTERNET" /> <uses-permissionandroid:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permissionandroid:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permissionandroid:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permissionandroid:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permissionandroid:name="android.permission.READ_PHONE_STATE" /> <uses-permissionandroid:name="android.permission.MANAGE_ACCOUNTS"/> <uses-permissionandroid:name="android.permission.GET_ACCOUNTS"/> <!-- 蓝牙分享所需的权限 --> <uses-permissionandroid:name="android.permission.BLUETOOTH" /> <uses-permissionandroid:name="android.permission.BLUETOOTH_ADMIN" />
2.添加activity信息 (tencent后面的appid要保持和您配置的QQ的appid一致)
<activity android:name="com.mob.tools.MobUIShell" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:configChanges="keyboardHidden|orientation|screenSize" android:screenOrientation="portrait" android:windowSoftInputMode="stateHidden|adjustResize"> <intent-filter> <dataandroid:scheme="tencent100371282" /> <actionandroid:name="android.intent.action.VIEW" /> <categoryandroid:name="android.intent.category.BROWSABLE" /> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> <!-- 调用新浪原生SDK,需要注册的回调activity --> <intent-filter> <action android:name="com.sina.weibo.sdk.action.ACTION_SDK_REQ_ACTIVITY"/> <category android:name="android.intent.category.DEFAULT"/> </intent-filter> </activity>
3.如果您集成了微信,易信,新浪微博支付宝还需要添加下面回调的activity处理;
<!--微信分享回调 -->
<span style="white-space:pre"></span><activity <span style="white-space:pre"></span>android:name=".wxapi.WXEntryActivity" <span style="white-space:pre"></span>android:theme="@android:style/Theme.Translucent.NoTitleBar" <span style="white-space:pre"></span>android:configChanges="keyboardHidden|orientation|screenSize" <span style="white-space:pre"></span>android:exported="true" <span style="white-space:pre"></span>android:screenOrientation="portrait" /> <span style="white-space:pre"></span><!--易信分享回调 --> <span style="white-space:pre"></span><activity <span style="white-space:pre"></span>android:name=".yxapi.YXEntryActivity" <span style="white-space:pre"></span>android:theme="@android:style/Theme.Translucent.NoTitleBar" <span style="white-space:pre"></span>android:configChanges="keyboardHidden|orientation|screenSize" <span style="white-space:pre"></span>android:exported="true" <span style="white-space:pre"></span>android:screenOrientation="portrait" /> <span style="white-space:pre"></span><!-- 支付宝分享回调 --><span style="white-space:pre"></span><activity <span style="white-space:pre"></span>android:name=".apshare.ShareEntryActivity" <span style="white-space:pre"></span>android:theme="@android:style/Theme.Translucent.NoTitleBar" <span style="white-space:pre"></span>android:configChanges="keyboardHidden|orientation|screenSize"<span style="white-space:pre"></span>android:exported="true"/>
11.添加一键分享代码
<span style="white-space:pre"></span>private void showShare() { <span style="white-space:pre"></span>ShareSDK.initSDK(this);// <span style="white-space:pre"></span>OnekeyShare oks = newOnekeyShare(); <span style="white-space:pre"></span>//关闭sso授权 <span style="white-space:pre"></span>oks.disableSSOWhenAuthorize(); <span style="white-space:pre"></span>// 分享时Notification的图标和文字 2.5.9以后的版本不调用此方法 <span style="white-space:pre"></span>//oks.setNotification(R.drawable.ic_launcher,getString(R.string.app_name));<span style="white-space:pre"></span> // title标题,印象笔记、邮箱、信息、微信、人人网和QQ空间使用 <span style="white-space:pre"></span>oks.setTitle(getString(R.string.share)); <span style="white-space:pre"></span>// titleUrl是标题的网络链接,仅在人人网和QQ空间使用 <span style="white-space:pre"></span>oks.setTitleUrl("http://sharesdk.cn"); <span style="white-space:pre"></span>// text是分享文本,所有平台都需要这个字段 <span style="white-space:pre"></span>oks.setText("我是分享文本"); <span style="white-space:pre"></span>// imagePath是图片的本地路径,Linked-In以外的平台都支持此参数 <span style="white-space:pre"></span>//oks.setImagePath("/sdcard/test.jpg");//确保SDcard下面存在此张图片 <span style="white-space:pre"></span>// url仅在微信(包括好友和朋友圈)中使用 <span style="white-space:pre"></span>oks.setUrl("http://sharesdk.cn"); <span style="white-space:pre"></span>// comment是我对这条分享的评论,仅在人人网和QQ空间使用 <span style="white-space:pre"></span>oks.setComment("我是测试评论文本"); <span style="white-space:pre"></span>// site是分享此内容的网站名称,仅在QQ空间使用 <span style="white-space:pre"></span>oks.setSite(getString(R.string.app_name)); <span style="white-space:pre"></span>// siteUrl是分享此内容的网站地址,仅在QQ空间使用 <span style="white-space:pre"></span>oks.setSiteUrl("http://sharesdk.cn"); <span style="white-space:pre"></span>// 启动分享GUI <span style="white-space:pre"></span>oks.show(this); <span style="white-space:pre"></span>}
12.配置各平台配置信息 介绍两种方法
1. ShareSDK.xml配置(参考\ShareSDK for Android\Res\ShareSDK.xml)
<span style="white-space:pre"></span><ShareSDK AppKey="填写您在ShareSDK上注册到的AppKey"/><span style="white-space:pre"></span><SinaWeibo <span style="white-space:pre"></span>SortId="此平台在您分享列表中的位置,整型,数值越大越靠后" <span style="white-space:pre"></span>AppKey="填写您在新浪微博上注册到的AppKey" <span style="white-space:pre"></span>AppSecret="填写您在新浪微博上注册到的AppSecret" <span style="white-space:pre"></span>Id="自定义字段,整型,用于您项目中对此平台的识别符" <span style="white-space:pre"></span>RedirectUrl="填写您在新浪微博上注册的RedirectUrl" <span style="white-space:pre"></span>ShareByAppClient="是否使用客户端进行分享" <span style="white-space:pre"></span>Enable="布尔值,标记此平台是否有效"/>
2.代码配置(各平台)参数参考ShareSDK.xml
<span style="white-space:pre"></span>ShareSDK.initSDK(Context,"你的应用在Sharesdk注册时返回的AppKey");<span style="white-space:pre"></span>HashMap<String,Object> hashMap = new HashMap<String,Object>(); <span style="white-space:pre"></span>hashMap.put("Id","1"); <span style="white-space:pre"></span>hashMap.put("SortId","1"); <span style="white-space:pre"></span>hashMap.put("AppKey","568898243"); <span style="white-space:pre"></span>hashMap.put("AppSecret","38a4f8204cc784f81f9f0daaf31e02e3"); <span style="white-space:pre"></span>hashMap.put("RedirectUrl","http://www.sharesdk.cn"); <span style="white-space:pre"></span>hashMap.put("ShareByAppClient","true"); <span style="white-space:pre"></span>hashMap.put("Enable","true"); <span style="white-space:pre"></span>ShareSDK.setPlatformDevInfo(SinaWeibo.NAME,hashMap);
13.在lua客户端调用显示广告
local luaj = require "cocos.cocos2d.luaj" local className = "com/locojoytj/sdk/Lua2Java" --java类名 local sigs = "(Ljava/lang/String;)Ljava/lang/String;" --参数类型 返回类型 if type(args)=="table" then args={json.encode(args)} end local ok,ret =luaj.callStaticMethod(className,"callJavaCommand",args,sigs) --调用 if ok then print("调用callJavaCommand方法成功!) else print("调用callJavaCommand方法失败!!!") end
- ShareSDK Android接入cocos2d-X lua
- Unity 接入 Android ShareSDK
- Cocos2d-x shareSDK
- Cocos2d-X-Lua Android移植
- cocos2d-x集成sharesdk做微信分享android,ios
- cocos2d-x接入
- 创建 cocos2d-x+lua for android 步骤
- 《Cocos2d-x lua for android 篇》
- cocos2d-x + lua在Android移植
- 《Cocos2d-x lua for android 篇》
- cocos2d-x手机游戏(IOS版本)接入分享shareSDK(新浪微博和微信分享)记录
- cocos2d-x 与 lua
- Cocos2d-x Lua action
- cocos2d-x嵌入lua
- cocos2d-x lua开发
- Cocos2d-x lua 触屏
- cocos2d-x lua
- cocos2d-x lua 定时器
- jsp中的contentType与pageEncoding的区别和作用http://www.cnblogs.com/freewater/archive/2011/12/21/2295827.html
- HTTP 错误 404.17 - Not Found 请求的内容似乎是脚本,因而将无法由静态文件处理程序来处理。
- HDU-3652 B-number (数位dp)
- onCreate方法中调用PopupWindow的错误
- 24.Android Studio报错:non-zero exit value 2
- ShareSDK Android接入cocos2d-X lua
- MySQL权限篇之EVENT及EXECUTE
- 埃拉托色尼(Eratosthenes)筛法
- Xcode7.3编译unity导出工程出现 Error "unknown type name __declspec" after Xcode 7.3 upgrade
- ViewPager如何阻止其滑动和一次切换多页闪烁的问题
- a definer ('root'@'%') does not exist
- Android5.0 之 ToolBar与DrawerLayout配合使用
- fibonacci 数列的快速幂求法
- Linux之下MySQL安装的三种方案的比较