当前位置:K88软件开发文章中心编程语言APP编程CrossApp → 文章内容

CADevice

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-23 13:52:42

由 ?﹏???ζ???﹏﹏? 创建, 最后一次修改 2016-09-08 类说明在移动开发过程中,常常要遇到调用移动设备的需求,如调用摄像头、通信录、wifi列表、蓝牙等等。CrossApp也为我们提供了调用Android和IOS平台设备的统一接口,我们只需要在CrossApp写统一的调用,然后在Android和IOS平台设置相对的权限,这样引擎会根据不同的平台去调用相应的执行,达到一样的效果。CrossApp引擎中为我们提供设置调用的为CADevice,它在引擎的extensions\device目录下。我们想要使用CADevice时,需要引入:#include "CrossAppExt.h"并声明命名空间:USING_NS_CC_EXT;基类CAObjectCADevice 方法(点击查看方法介绍)方法说明getSystemVersionWithIOS获取IOS系统版本getAppVersion获取app版本openCamera打开相机openAlbum打开相册getScreenBrightness获取屏幕亮度setScreenBrightness设置屏幕亮度writeToSavedPhotosAlbum保存到相册getAddressBook获取通信录updateVersion更新版本getNetWorkType获取网络类型getWifiListWithAndroid获取WiFi列表setVolume设置音量getVolume获取音量OpenURL打开网址(调用浏览器打开网址)getBatteryLevel获取电池电量isNetWorkAvailble查看是否连接到网络sendLocalNotification发送本地通知getWifiConnectionInfo获取WiFi连接信息initBlueTooth初始化蓝牙setBlueToothType设置蓝牙类型startGyroscope开始陀螺仪setGyroInterval陀螺间隔stopGyroscope停止陀螺仪通过上面的函数列表我们可以清楚的知道,CrossApp为我们提供的设备调用函数,但我还有时还需要实现相应的代理,才能获得想要的信息,比如调用摄像机拍照后,我们想要获得照片,那么我们必须要实现CAMediaDelegate代理,这我们才能获得这张照片的问题。我们这里查看一这些代理函数:摄像头代理:class CC_DLL CATabBarItem : public CABarItem{ public: static CATabBarItem* create(const std::string& title, CAImage* image, CAImage* selectedImage = NULL); public: CATabBarItem(); virtual ~CATabBarItem(); bool init(const std::string& title, CAImage* image, CAImage* selectedImage = NULL); //获得照片纹理 CC_SYNTHESIZE_RETAIN(CAImage*, m_pSelectedImage, SelectedImage); //标签 CC_SYNTHESIZE_PASS_BY_REF(std::string, m_pBadgeValue, BadgeValue); };蓝牙代理:class CC_DLL CABlueToothDelegate{public: virtual ~CABlueToothDelegate(){}; //蓝牙状态 virtual void getBlueToothState(CABlueToothState state) {}; //蓝牙设备信息 virtual void getSearchBlueToothDevice(CABlueToothUnit unit){}; //开始查找蓝牙设备 virtual void startDiscoveryBlueToothDevice(){}; //找到蓝牙设备 virtual void finishedDiscoveryBlueToothDevice(){};};WIFI代理:class CC_DLL CAWifiDelegate{public: virtual ~CAWifiDelegate(){}; //wifi信息 virtual void getWifiListFunc(std::vector<CAWifiInfo> _wifiInfoList) = 0;};CADevice  方法介绍 CC_DLL const char* getSystemVersionWithIOS();返回值:const char* 参数:解释:获取IOS系统版本CC_DLL const char* getAppVersion();返回值:const char*参数:解释:获取app版本CC_DLL void openCamera(CAMediaDelegate* target);返回值:void参数:类型参数名说明CAMediaDelegate*target媒体代理解释:打开相机CC_DLL void openAlbum(CAMediaDelegate* target);返回值:void参数:类型参数名说明CAMediaDelegate* target媒体代理解释:打开相册CC_DLL float getScreenBrightness();返回值:float参数:解释:获取屏幕亮度CC_DLL void setScreenBrightness(float brightness);返回值:void参数:类型参数名说明floatbrightness屏幕亮度解释:设置屏幕亮度CC_DLL void writeToSavedPhotosAlbum(const std::string &s);返回值:void参数:类型参数名说明const std::string&s相册解释:保存到相册CC_DLL std::vector<CAAddressBookRecord> getAddressBook();返回值:std::vector<CAAddressBookRecord>参数:解释:获取通信录CC_DLL void updateVersion(const std::string &url ,unsigned int versionNumber ,const std::string &appId);返回值:void参数:类型参数名说明onst std::string&url网址unsigned int versionNumber版本号const std::string&appIdAppID解释:更新版本CC_DLL CANetWorkType getNetWorkType();返回值:CANetWorkType参数:解释:获取网络类型CC_DLL void getWifiListWithAndroid(CAWifiDelegate *target);返回值:void参数:类型参数名说明CAWifiDelegatetargetWiFi代理解释:获取WiFi列表(Android)CC_DLL void setVolume(float sender, int type);返回值:void参数:类型参数名说明floatsender音量inttype类型解释:设置音量CC_DLL float getVolume(int type);返回值:float参数:类型参数名说明inttype类型解释:获取音量CC_DLL void OpenURL(const std::string &url);返回值:void参数:类型参数名说明const std::string &url网址解释:打开网址(调用浏览器打开网址)CC_DLL float getBatteryLevel();返回值:float参数:解释:获取电池电量CC_DLL bool isNetWorkAvailble();返回值:bool参数:解释:查看是否连接到网络CC_DLL void sendLocalNotification(const char* title, const char* content, unsigned long time);返回值:void参数:类型参数名说明const char* title标题const char*content内容unsigned longtime时间解释:发送本地通知CC_DLL CAWifiInfo getWifiConnectionInfo();返回值:CAWifiInfo参数:解释:获取WiFi连接信息CC_DLL void initBlueTooth(CABlueToothDelegate *target);返回值:void参数:类型参数名说明CABlueToothDelegate*target蓝牙代理解释:初始化蓝牙CC_DLL void setBlueToothType(CABlueToothType type);返回值:void参数:类型参数名说明CABlueToothTypetype蓝牙类型解释:设置蓝牙类型typedef enum{ CABLUETOOTHOPEN = 0, //开蓝牙

[1] [2]  下一页


CADevice