[工作积累] Google Play Services
注意添加APP_ID
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="@string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
使用对应的AndroidInitialization方法
gpg-cpp-sdk/android/include/gpg/android_initialization.h
/**
* @file gpg/android_initialization.h
*
* @brief Android specific initialization functions.
*/ #ifndef GPG_ANDROID_INITIALIZATION_H_
#define GPG_ANDROID_INITIALIZATION_H_ #ifndef __cplusplus
#error Header file supports C++ only
#endif // __cplusplus #include <android/native_activity.h>
#include <jni.h>
#include "gpg/common.h" // Forward declaration of android_app from android_native_app_glue.h.
struct android_app; namespace gpg { /**
* AndroidInitialization includes three initialization functions, exactly one of
* which must be called. In the case of a standard Java Activity, JNI_OnLoad
* should be used. In the case of a NativeActivity where JNI_OnLoad will not be
* called, either android_main or ANativeActivity_onCreate should be used.
* android_main is used when building a NativeActivity using
* android_native_app_glue.h. ANativeActivity_onCreate is used when building a
* NativeActivity using just native_activity.h. android_native_app_glue.h and
* native_activity.h are default Android headers.
*
* The appropriate initialization function must be called exactly once before
* any AndroidPlatformConfiguration instance methods are called, and it must be
* called before a GameServices object is instantiated. It is permitted to
* instantiate a AndroidPlatformConfiguration before one of the intialization
* calls (for example, if the configuration object has global scope), as long as
* no methods are called before the initialization call. These methods need be
* called only once in the lifetime of the calling program, not once per
* GameServices object created.
*/
struct GPG_EXPORT AndroidInitialization {
/**
* When using Play Game Services with a standard Java Activity, JNI_OnLoad
* should be called when the dynamic library's JNI_OnLoad is called.
*/
static void JNI_OnLoad(JavaVM *jvm); /**
* When using Play Game Services with a NativeActivity which is based on
* android_native_app_glue.h, android_main should be called during your
* activity's android_main, before any other Play Game Services calls.
*/
static void android_main(struct android_app *app); /**
* When using Play Game Services with a NativeActivity which is based on only
* native_activity.h, ANativeActivity_onCreate should be called during your
* activity's ANativeActivity_onCreate, before any other Play Game Services
* calls.
*/
static void ANativeActivity_onCreate(ANativeActivity *native_activity,
void *savedState,
size_t savedStateSize);
}; } // namespace gpg #endif // GPG_ANDROID_INITIALIZATION_H_
API Level 14以上: OnActivityResult必须调用, 其他不需要. 14以下都需要.
gpg-cpp-sdk/android/include/gpg/android_support.h
#ifndef __cplusplus
#error Header file supports C++ only
#endif // __cplusplus #include "gpg/common.h" namespace gpg { /**
* Functions which enable pre- Android 4.0 support.
*
* <h1>Android Lifecycle Callbacks</h1>
*
* For apps which target Android 2.3 or 3.x devices (API Version prior to 14),
* Play Game Services has no way to automatically receive Activity lifecycle
* callbacks. In these cases, Play Game Services relies on the owning Activity
* to notify it of lifecycle events. Any Activity which owns a GameServices
* object should call the AndroidSupport::* functions from within their own
* lifecycle callback functions. The arguments in these functions match those
* provided by Android, so no additional processing is necessary.
*
* For apps which target android 4.0+ (API Version greater than or equal to 14),
* most of these function calls are unnecessary. For such apps only the
* OnActivityResult function must be called.
...
Update: IAP/Google IAB
ref: http://developer.android.com/google/play/billing/billing_testing.html
遇到的问题:
response code 4: item unavailable
"the item you requested is not available for purchase"
http://developer.android.com/google/play/billing/v2/billing_reference.html
RESULT_ITEM_UNAVAILABLE 4
Indicates that Google Play cannot find the requested item in the application's product list. This can happen if the product ID is misspelled in your
REQUEST_PURCHASErequest or if an item is unpublished in the application's product list.
Check list: (answered by nmw01223)
http://stackoverflow.com/questions/11020587/in-app-billing-item-requested-not-available-for-purchase
对照检查, 我这里的问题是第6条:
dev console上上传的的APK, versionCode为6, 设备测试用的APK, versionCode 12.
将本地设备使用的版本号改为6, 问题解决. 估计将新版本的APK上传到dev console也可以解决这个问题.
[工作积累] Google Play Services的更多相关文章
- [工作积累] Google/Amazon平台的各种坑
所谓坑, 就是文档中没有标明的特别需要处理的细节, 工作中会被无故的卡住各种令人恼火的问题. 包括系统级的bug和没有文档化的限制. 继Android的各种坑后, 现在做Amazon平台, 遇到的坑很 ...
- [工作积累] Google Play Game SDK details
https://developers.google.com/games/services/cpp/api/structgpg_1_1AndroidSupport For apps which targ ...
- unity3d 导入google play services插件工程
最近在给unity工程尝试接入google play services插件,遇到了些问题,记录一下. 之前在做android插件的时候,都是自己创建一个android工程,把生成的.class文件打包 ...
- [工作积累] android 中添加libssl和libcurl
1. libssl https://github.com/guardianproject/openssl-android 然后执行ndk-build 2.libcurl 源代码组织结构, 下面的mak ...
- [工作积累] 32bit to 64bit: array index underflow
先贴一段C++标准(ISO/IEC 14882:2003): 5.2.1 Subscripting: 1 A postfix expression followed by an expression ...
- [工作积累] bitfield
ISO/IEC 14882:2003: 9.6 Bit-fields [class.bit] A member-declarator of the form identifieropt : const ...
- [工作积累] GCC 4.6 new[] operator内存对齐的BUG
对于用户没有定义dctor(包括其所有成员)的类来说, new CLASS[n] 可能会直接请求sizeof(CLASS)*n的空间. 而带有dctor的 类, 因为delete[]的时候要逐个调用析 ...
- [工作积累] UE4 并行渲染的同步 - Sync between FParallelCommandListSet & FRHICommandListImmediate calls
UE4 的渲染分为两个模式1.编辑器是同步绘制的 2.游戏里是FParallelCommandListSet并行派发的. mesh渲染也分两类,static mesh 使用TStaticMeshDra ...
- [工作积累] D3D10+ 中 Pixel Shader 的input semantic和参数顺序
由于semantic的使用,我们有理由相信 vertex shader的output 和 pixel shader的input是按照semantic来匹配的,而跟传入顺序无关.印象dx9时代是这样. ...
随机推荐
- Curve 曲线 工具
最近研究了曲线绘制的工具,主要是2D方程的绘制.综合了许多工具,完成了一下两个脚本. 绘制的工具: using UnityEngine; using System.Collections; using ...
- pytorch预训练
Pytorch预训练模型以及修改 pytorch中自带几种常用的深度学习网络预训练模型,torchvision.models包中包含alexnet.densenet.inception.resnet. ...
- ubuntu 18.04启动samba图形管理界面
启动samba图形界面管理器出现错误: Failed to load module "canberra-gtk-module" 或 SystemError: could not o ...
- 运维seq语法
seq-print a sequence of numbers 用于产生从某个数到另外一个数之间的所有整数 语法:seq 开始列 指定步长 结束列 参数: -f :指定输出格式,允许使用print ...
- 再见了,我最爱的OI~~~
唔,迟到了三个月的感言呢. 我就这样离开OI了,成为了一个退役的OIer,当年高一的时候还觉得自己有很多时间,没想转眼间自己就退役了.呵呵,来到OI 从没有在这个世界带起一丝风浪,也没有拿到一个满意的 ...
- esLint 配置
默认eslint规则: 代码末尾不能加分号 ;(强迫症的我受不了)代码中不能存在多行空行:(这个我更也忍不了)tab键不能使用,必须换成两个空格:(超级不习惯)代码中不能存在声明了但未使用的变量:(这 ...
- C# WebSocket
WebSocket 协议用于完全双工的双向通信.这种通信,一般在浏览器和Web服务器之间进行,但仅交流那些支持使用WebSocket协议的客户端信息.WebSocket维持一个打开的连接. Tcp发送 ...
- javascript 对象数组排序(按照科目级次)
需求 从后台获取的数据是这样的 上帝要这样的 背景 从后台获取到表格数据,然后填充到excel.当然是用js来填充的.js 本身的数组具有sort()功能.但是是针对 ...
- ---————for循环打印爱心
//打印爱心public class Xin{ public static void main (String [] args){ for(int i=1;i<=4;i++){ for(int ...
- 网络知识--OSI七层网络与TCP/IP五层网络架构及二层/三层网络
作为一个合格的运维人员,一定要熟悉掌握OSI七层网络和TCP/IP五层网络结构知识. 废话不多说!下面就逐一展开对这两个网络架构知识的说明:一.OSI七层网络协议OSI是Open System Int ...