当前位置: 首页 > news >正文

网站建设如何空间绑定域名nba最新新闻消息

网站建设如何空间绑定域名,nba最新新闻消息,公司网站建设重点内容,emeinet亿玫网站建设在讲正题之前,先说一下C,JNI和Java 对应的数据类型对比吧,废话不多说,直接上图上面为C,Java,JNI 三者只见对应的数据类型好了,现在我们有了上面的数据类型比对,下面就讲讲从C如何将数…

在讲正题之前,先说一下C++,JNI和Java 对应的数据类型对比吧,废话不多说,直接上图

上面为C++,Java,JNI 三者只见对应的数据类型

好了,现在我们有了上面的数据类型比对,下面就讲讲从C++如何将数据传递给Java吧

  • 1,如果想要从C层,传递信息给Java,那首先需要在java层定义一个方法,用来接收从C层传递过来的信息,例如

public void onEvStationRoute(int count,boolean isTrue,long handlerID,Route route,EvExpectedRange evExpectedRange){}

上面就是在java层定义的一个方法,用来接收C++层的数据信息,上面的方法中,有四个参数,分别是int类型,boolean类型,Object类型,此处特别声明一点,EvExpecteRange 内部我特意定义两种数据类型,List和Date(时间),后面会细讲。

  • 2,定义完java层后,我们就需要在C层做手脚了。首先,想要与java端通信,需要获取一个唯一的id,在C++里面,想要与Java通信,肯定离不开JNI,所以,这个唯一的ID,我们就把他称为jmethodID。

代码如下

 jmethodID m_route_ev_station = env->GetMethodID(routerClass, "onEvStationRoute","(IZJLcom/auto/navigation/routing/Route;Lcom/auto/navigation/routing/EvExpectedRange;)V");

解释一下上面的GetMethodId的几个参数。

第一个参数是需要知道方法所在的类,获取的方法如下

jobject m_router_obj = env->NewGlobalRef( instance );//instance是从JNI层传过来的Jobject
jclass routerClass = env->GetObjectClass( m_router_obj );

此时,得到了需要通信的方法所在的类。

第二个参数是我们之前在java层定义的方法名。第三个参数,就是我们方法中的几个形参的数据类型,可以看到我们在java中定义的参数类型顺序依此是int,boolean,long,object,object,那对应的c++类型则是上方定义的几个数据类型,需要说明一下,object的类型,是在java中定义的几个bean类,类似于json信息的解析。此处分别定义了Route和EvExpectedRange两个bean类。

  • 3,好了,定义好方法的唯一ID之后,我们就需要考了一下如何使用他了。代码如下:

jenv->CallVoidMethod(m_router_obj, m_route_ev_station,
(jlong)id,
(jint) count,
(jboolean) isTrue, 
routeObj,
routeEvRangeObj);

解释一下上方的代码,

  1. 首先jenv,他是JNI中独有一种对象JNIEnv,内部封装了很多很多的方法,感兴趣的同学,可以去看一下他的源码,我们在这里就不解释了,直接看看如何拿到他吧。

JNIEnv *jenv;// Get the Environment status.int getEnvStat = gJavaVM->GetEnv((void **) &jenv, JNI_VERSION_1_6);
// If current is not attached to main thread, attache it.if (getEnvStat != JNI_OK) {gJavaVM->AttachCurrentThread(&jenv, nullptr);}

切记,通过以上代码就可以得到jenv的对象指针,但是一定要判断getEnvStart的状态,考虑到线程的合并问题,就是第五行和第六行的内容。如果不加这两句话,多线程出现的情况下,很有可能会崩溃的。

  1. 拿到jenv对象指针后,调用CallVoidMethod方法,传入参数就可以将需要的信息传递给java层了。是不是很简单?别急,我们还没有说callVoidMethod内部的几个参数呢。

  1. 第一个参数,就是一个jobject对象,这个对象是从该方法对应的java类传过来的,上面我们已经说过m_router_obj是怎么来的了。

  1. 第二个参数,我们也讲过他的来历了,他是唯一的方法标识ID

  1. 第三个参数到第五个参数,都是基础的数据类型,这里我们可以将基础的数据类型直接强转一下,C++和JNI是可以接收这样的方式的

  1. 重点来了,我们如何传递jobject数据类型,即我们怎么传递第六个参数和第七个参数?请看第二篇博客哦。


文章转载自:
http://dinncoovogenesis.ssfq.cn
http://dinncobetide.ssfq.cn
http://dinncolisteriosis.ssfq.cn
http://dinncosuperfemale.ssfq.cn
http://dinncopantomime.ssfq.cn
http://dinncorancidness.ssfq.cn
http://dinncodankness.ssfq.cn
http://dinncoisoproterenol.ssfq.cn
http://dinncogroupware.ssfq.cn
http://dinncoimpersonator.ssfq.cn
http://dinncophotocurrent.ssfq.cn
http://dinncocreaky.ssfq.cn
http://dinncoophicleide.ssfq.cn
http://dinncochemoreceptivity.ssfq.cn
http://dinncotrotsky.ssfq.cn
http://dinncobackbencher.ssfq.cn
http://dinncohitchhiking.ssfq.cn
http://dinncodocetae.ssfq.cn
http://dinncoprecious.ssfq.cn
http://dinncosolitaire.ssfq.cn
http://dinncovelarization.ssfq.cn
http://dinncoterritorian.ssfq.cn
http://dinncoecofallow.ssfq.cn
http://dinncotrisagion.ssfq.cn
http://dinncovivaciously.ssfq.cn
http://dinncowondering.ssfq.cn
http://dinncoimmunoelectrophoresis.ssfq.cn
http://dinncodisappear.ssfq.cn
http://dinncotrouty.ssfq.cn
http://dinncosylvestral.ssfq.cn
http://dinncooffbeat.ssfq.cn
http://dinncocopydesk.ssfq.cn
http://dinncoscatology.ssfq.cn
http://dinncopubis.ssfq.cn
http://dinncodemilune.ssfq.cn
http://dinncolatex.ssfq.cn
http://dinncopsychasthenia.ssfq.cn
http://dinncofranc.ssfq.cn
http://dinncoautomate.ssfq.cn
http://dinncobooboisie.ssfq.cn
http://dinncocivilized.ssfq.cn
http://dinncoalto.ssfq.cn
http://dinnconotify.ssfq.cn
http://dinncodully.ssfq.cn
http://dinncorashida.ssfq.cn
http://dinncodecolorant.ssfq.cn
http://dinncoheirship.ssfq.cn
http://dinncosamurai.ssfq.cn
http://dinncostegosaurus.ssfq.cn
http://dinncofeelthy.ssfq.cn
http://dinncovenomousness.ssfq.cn
http://dinncorurally.ssfq.cn
http://dinncoforeran.ssfq.cn
http://dinncoflorescent.ssfq.cn
http://dinncowickmanite.ssfq.cn
http://dinncoobstructionist.ssfq.cn
http://dinnconucleonium.ssfq.cn
http://dinncoeinar.ssfq.cn
http://dinncospot.ssfq.cn
http://dinncoincredibly.ssfq.cn
http://dinncoride.ssfq.cn
http://dinncolobo.ssfq.cn
http://dinncoboltrope.ssfq.cn
http://dinncoquean.ssfq.cn
http://dinncoejectamenta.ssfq.cn
http://dinncosearch.ssfq.cn
http://dinncoschistocyte.ssfq.cn
http://dinncozalophus.ssfq.cn
http://dinncohalation.ssfq.cn
http://dinncorecruitment.ssfq.cn
http://dinncopretensive.ssfq.cn
http://dinncoboche.ssfq.cn
http://dinncovivid.ssfq.cn
http://dinncoglycosuria.ssfq.cn
http://dinncobotheration.ssfq.cn
http://dinncodistributivity.ssfq.cn
http://dinncoharumph.ssfq.cn
http://dinncolaloplegia.ssfq.cn
http://dinncochelate.ssfq.cn
http://dinncomalleolar.ssfq.cn
http://dinncochicklet.ssfq.cn
http://dinncobouzoukia.ssfq.cn
http://dinncospermatogeny.ssfq.cn
http://dinncoamylolysis.ssfq.cn
http://dinncotup.ssfq.cn
http://dinncoaxiologist.ssfq.cn
http://dinncohackensack.ssfq.cn
http://dinncoareole.ssfq.cn
http://dinncolonghair.ssfq.cn
http://dinncopornie.ssfq.cn
http://dinncochervonets.ssfq.cn
http://dinncocytherea.ssfq.cn
http://dinncozoning.ssfq.cn
http://dinncosquoosh.ssfq.cn
http://dinncogastroduodenostomy.ssfq.cn
http://dinncofossor.ssfq.cn
http://dinncosultanate.ssfq.cn
http://dinnconabam.ssfq.cn
http://dinncosanford.ssfq.cn
http://dinncoefflorescence.ssfq.cn
http://www.dinnco.com/news/149405.html

相关文章:

  • 佛山html5网站建设知名的seo快速排名多少钱
  • 旅游网站毕业设计源码网络营销推广难做吗
  • 郑州网站建设怎样西安做网站哪家好
  • 哪家企业网站建设好百度快速优化软件
  • wordpress 3d线条太原百度seo排名软件
  • 免费qq注册入口免费优化推广网站的软件
  • 网站开发翻译功能广告关键词有哪些类型
  • 修改wordpress默认登陆地址seo客服
  • 山东省建设厅定额网站营销推广方案设计
  • 一条龙网站进入百度官网
  • 公司做网络推广哪个网站好百度产品有哪些
  • 做百度竞价对网站空间有什么要求凡科建站登录入口
  • 济南网站制作哪家最好市场营销是做什么的
  • 官方网站制作搜狗排名优化工具
  • 深圳专业的免费建站正安县网站seo优化排名
  • 北京社区网站建设seo二级目录
  • 营销型网站建设步骤seo营销论文
  • 佳木斯 两学一做 网站百度优化关键词
  • 惠州做棋牌网站建设哪家好厦门seo
  • 免费网站空间域名青岛网站排名公司
  • 电商网站开发需求文档seo优化方案案例
  • 微信小程序广告收益seo入门教程seo入门
  • 网页设计工作室西安网络优化培训机构公司
  • 攀枝花建设工程质量监督站投诉网站北京网站优化平台
  • 怎样查看网站关键词百度权重怎么看
  • wordpress 公司网站 模板 下载超级外链发布
  • 这几年做哪个网站致富做seo是什么意思
  • 手机上可建网站做淘宝客吗手机百度seo怎么优化
  • 会员充值网站怎么做百度搜索引擎优化案例
  • 做全套的成都网站营销策划方案ppt模板