标签:
cocos2d中的C++代码会编译成一个.so文件,放在安卓目录下的libs/armeabi 下,然后java会load进来,这步我们不用做了,因为cocos2d已经帮我们做好了。
package cb.CbCCBLE; public class CbCCBLECentralManager { public static final String TAG = "CbCCBLECentralManager Android"; public native static void bleCenterManagerNotificationChangeState(int oldState, int newState); public native static void bleCenterManagerNotificationDidScanOnePeripheral(String peripheralId); public native static void bleCenterManagerNotificationDidFinishScanning(); }
extern "C" { //test void Java_cb_CbCCBLE_CbCCBLECentralManager_bleCenterManagerNotificationChangeState(JNIEnv* env, jobject thiz, jint oldState, jint newState) { CCLOG("Java_cb_CbCCBLE_CbCCBLECentralManager_bleCenterManagerNotificationChangeState"); CCLOG("oldState:%d, newState:%d", (int)oldState, (int)newState); } void Java_cb_CbCCBLE_CbCCBLECentralManager_bleCenterManagerNotificationDidScanOnePeripheral(JNIEnv* env, jobject thiz, jstring peripheralId) { CCLOG("Java_cb_CbCCBLE_CbCCBLECentralManager_bleCenterManagerNotificationDidScanOnePeripheral"); std::string peripheralId = JniHelper::jstring2string(peripheralId); CCLOG("%s", peripheralId.c_str()); } void Java_cb_CbCCBLE_CbCCBLECentralManager_bleCenterManagerNotificationDidFinishScanning(JNIEnv* env, jobject thiz) { CCLOG("Java_cb_CbCCBLE_CbCCBLECentralManager_bleCenterManagerNotificationDidFinishScanning"); } }
http://www.waitingfy.com/archives/1651
标签:
原文地址:http://blog.csdn.net/fox64194167/article/details/44409675