1.将腾讯jar和so文件放到libs目录下:
libAppleJuice.so
libdes3jni.so
AppleJuice.jar
ApplePay.jar
2. 将腾讯的res覆盖到项目res目录下, 注意腾讯是2个sdk,res要合并
3. 将manifest中添加腾讯需要的项,具体参考腾讯文档
4. 初始化java代码
- AppleJuice.Initialized(getInstance());
- AJAuthService.SetDelegate(getInstance());
- AppleJuiceService.SetDelegate(getInstance());
- Log.i("jnitest", "-----------QQ pay start-------");
- ApplePay.Initialized(this);
- APPayGameService.SetDelegate(this);
- APUserCenterService.SetDelegate(this);
- APPayCenterService.SetDelegate(this);
- APGameBalanceService.SetDelegate(this);
5. 登陆框弹出,第三个参数为设置获取数平数据(支付用)和sessionkey(登陆返回)
- long appid = 613008918;
- //AJAuthService.LaunchAuthView(false, (long)0x10, 0);
- //AJAuthService.LaunchAuthView(false, appid, AJAuthService.ST_SIG);
- AJAuthService.LaunchAuthView(false, appid, AJAuthService.S_KEY|AJAuthService.ST_SIG);
6.登出
- AppleJuiceService.Logout();
7. 活动中心
- AJActivityService.LaunchCenterView();
8. 支付页面
- public static String tmp =""; //skey
- public static String offerid = "1450000016";
- public static String uin = ""; // uer qq number
- public static void Click_qq_pay(int pay_id){
- Log.i("jnitest", "------------qq pay_id"+pay_id);
- HashMap<String, String> transInfo = new HashMap<String,String>();
- List<HashMap<String,String>> zoneinfo = new ArrayList<HashMap<String,String>>();
- HashMap<String, String> zone1 = new HashMap<String,String>();
- HashMap<String, String> zone2 = new HashMap<String,String>();
- HashMap<String, String> zone3 = new HashMap<String,String>();
- Log.i("jnitest", "------------skey:"+tmp);
- transInfo.put("skey", tmp); //S_KEY
- transInfo.put("offerid", offerid); //offerid
- uin = ""+Uin;
- transInfo.put("uin",uin); //qq hao
- Log.i("jnitest", "------------uin:"+uin);
- int channelid_ = AppleJuiceService.GetChannelID();
- Log.i("jnitest", "------------channelid_"+channelid_);
- transInfo.put("channelid", ""+channelid_);
- //transInfo.put("saveNumber", ""+15);
- zone1.put("zoneid", "0"); //不分大区的应用,默认传zoneid为0
- zone1.put("zonename", ""); //不分大区的应用,默认传zonename为空
- zoneinfo.add(zone1);
- //可选参数
- transInfo.put("amtedit", "0"); //amtedit为空或者没有赋值都认为可编辑,其它值表示不可编辑
- transInfo.put("amt1", "150");
- transInfo.put("amt2", "450");
- transInfo.put("amt3", "750");
- //APPayGameService.LaunchSaveCurrencyView(transInfo);
- APPayGameService.LaunchSaveCurrencyView(transInfo,zoneinfo);
- Log.i("jnitest", "------------qq pay_id end"+pay_id);
9. 支付成功的回调
- public void PaygameServiceSuccess(String resultcode, HashMap<String, String> successInfo) {
- // TODO Auto-generated method stub
- Log.i("jnitest", "-----------PaygameServiceSuccess");
- Log.i("jnitest", "------------qq resultcode"+resultcode);
- this.resultcode = resultcode;
- info = successInfo;
- // result1.setText(resultcode);
- int num = successInfo.size();
- String infoItem = "";
- for(int i=1; i<=num; i++)
- {
- String stri = Integer.toString(i);
- infoItem = infoItem + " " + info.get(stri) ;
- }
- // result2.setText(infoItem);
- Log.i("jnitest", "------------qq infoItem"+infoItem);
- nativeQQPayOK(0 , "");
- }
10. 登陆成功,获取数平认证和sessionkey
- public void AuthServiceSuccess(long arg0, HashMap<String, Object> arg1) {
- Log.i("jnitest", "---------AuthServiceSuccess ------");
- HideWaitDialog();
- String sessencekeys = "";
- Uin = arg0;
- String userName = "";
- userName = arg1.get("nickName").toString();
- byte [] bs = (byte[]) arg1.get("sKey");
- String bsss = new String (bs);
- byte [] sessencekey = (byte[]) arg1.get("stSig");
- sessencekeys = byte2HexStr(sessencekey);
- Log.i("jnitest", "--------bs ------:"+bs);
- Log.i("jnitest", "--------bsss ------:"+bsss);
- tmp = bsss;
- Log.i("jnitest", "---------userName ------"+userName);
- Log.i("jnitest", "---------Uin ------"+Uin);
- netiveQQLoginOK(""+Uin , sessencekeys);
- AppleJuiceService.Finish();
- Log.i("jnitest", "--------sessencekey ------:"+sessencekey);
- Log.i("jnitest", "--------sessencekeys ------:"+sessencekeys);
- }