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

中山祥云做的网站怎么样百度百科微信群推广

中山祥云做的网站怎么样百度百科,微信群推广,wordpress 360字体插件,网站是怎么建成的本文主要讲解Android NDK开发中JNIEnv、jobject与jclass的相关知识&#xff0c;并用c和c两种语言实现了jobject和jclass。 本专栏知识点是通过<零声教育>的音视频流媒体高级开发课程进行系统学习&#xff0c;梳理总结后写下文章&#xff0c;对音视频相关内容感兴趣的读者…

本文主要讲解Android NDK开发中JNIEnv、jobject与jclass的相关知识,并用c和c++两种语言实现了jobject和jclass。


本专栏知识点是通过<零声教育>的音视频流媒体高级开发课程进行系统学习,梳理总结后写下文章,对音视频相关内容感兴趣的读者,可以点击观看课程网址:零声教育


Android NDK开发(二)——JNIEnv、jobject与jclass关系

  • JNIEnv、jobject与jclass关系
  • jobject和jclass实现
  • 利用c语言实现

JNIEnv、jobject与jclass关系

JavaVM 和 Env 的关系

  1. JavaVm是虚拟机在jni层的代表,⼀个进程只有⼀个JavaVm,所有线程共⽤⼀个JavaVM。
  2. JNIEnv 是⼀个线程相关的结构体,它代表了java的运⾏环境 。每⼀个线程都会有⼀个,不同的线程中
    不能相互调⽤,每个JNIEnv都是线程专有的。 jni中可以拥有很多个JNIEnv,可以使⽤它来进⾏java层
    和native层的调⽤。
  3. JNIEnv 是⼀个指针,指向⼀个线程相关的结构,线程相关结构指向了JNI函数指针数组。这个数组⾥⾯
    定义了⼤量的JNI函数指针。
  4. 在同⼀个线程中,多次调⽤JNI层⽅法,传⼊的JNIEnv都是相同的。
  5. 在java层定义的本地⽅法,可以在不同的线程中调⽤,因此是可以接受不同的JNIEnv。

jobject和jclass区别:
jobject:实例引⽤(C++的说法:对象引⽤)(普通函数)
jclass: 类引⽤ (静态函数)

jobject和jclass实现

创建一个新项目,
java->com.example.ndk4_3->MainActivity文件中,添加声明

static public native String staticstringFromJNI();

在这里插入图片描述
之后利用java.h自动生成JNI接口
在这里插入图片描述
自动生成接口:
在这里插入图片描述
修改cpp->native-lib.cpp

extern "C" JNIEXPORT jstring JNICALL
Java_com_example_ndk4_13_MainActivity_staticstringFromJNI(JNIEnv *env,jclass){std::string hello = "Static Hello from C++";return env->NewStringUTF(hello.c_str());
}

此时调用的,普通函数就是jobject,静态函数就是jclass,与c++中类似,静态函数是属于整个类的,而普通函数属于每个对象的。
在这里插入图片描述
之后,修改对应文件,运行程序。
修改res->layout->activity_main.xml文件,设置布局

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><TextViewandroid:id="@+id/sample_text"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="50dp"android:text="Hello World!"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /><TextViewandroid:id="@+id/sample_text2"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_marginTop="100dp"android:text="Hello World!"app:layout_constraintStart_toStartOf="parent"app:layout_constraintTop_toTopOf="parent" /></androidx.constraintlayout.widget.ConstraintLayout>

布局预览如下:
在这里插入图片描述
修改java->com.example.ndk4_3->MainActivity文件

	TextView tv2 = findViewById(R.id.sample_text2);tv2.setText(staticstringFromJNI());

在这里插入图片描述
之后运行即可:
在这里插入图片描述

利用c语言实现

cpp->includes->CMaketList.txt中的native-lib.cpp修改为native-lib.c
在这里插入图片描述
新建一个native-lib.c如下

#include <jni.h>JNIEXPORT jstring JNICALL
Java_com_example_ndk4_13_MainActivity_stringFromJNI(JNIEnv *env,jobject obj/* this */) {char str[] = "Hello from C";return (*env)->NewStringUTF(env, str);
}
JNIEXPORT jstring JNICALL
Java_com_example_ndk4_13_MainActivity_staticstringFromJNI(JNIEnv *env,jclass jcs){char str[] = "Static Hello from C";return (*env)->NewStringUTF(env, str);
}

运行:
在这里插入图片描述


文章转载自:
http://diurnally.rdfq.cn
http://muckle.rdfq.cn
http://tommy.rdfq.cn
http://monostome.rdfq.cn
http://catenane.rdfq.cn
http://capnomancy.rdfq.cn
http://doubting.rdfq.cn
http://membranous.rdfq.cn
http://crushable.rdfq.cn
http://chanteur.rdfq.cn
http://horseleech.rdfq.cn
http://spirket.rdfq.cn
http://pentamer.rdfq.cn
http://apec.rdfq.cn
http://avignon.rdfq.cn
http://robertsonian.rdfq.cn
http://stu.rdfq.cn
http://derealize.rdfq.cn
http://aclinic.rdfq.cn
http://spree.rdfq.cn
http://cistus.rdfq.cn
http://mdr.rdfq.cn
http://fendillate.rdfq.cn
http://deprecation.rdfq.cn
http://slope.rdfq.cn
http://quinism.rdfq.cn
http://retaliative.rdfq.cn
http://undermine.rdfq.cn
http://pushup.rdfq.cn
http://giltwood.rdfq.cn
http://insusceptible.rdfq.cn
http://coarse.rdfq.cn
http://procreation.rdfq.cn
http://smokepot.rdfq.cn
http://teens.rdfq.cn
http://obstreperous.rdfq.cn
http://corrodibility.rdfq.cn
http://lengthily.rdfq.cn
http://carbonari.rdfq.cn
http://underhanded.rdfq.cn
http://pos.rdfq.cn
http://extragalactic.rdfq.cn
http://kedjeree.rdfq.cn
http://eyestrain.rdfq.cn
http://fendillate.rdfq.cn
http://isotac.rdfq.cn
http://nixonomics.rdfq.cn
http://feverroot.rdfq.cn
http://undies.rdfq.cn
http://enneahedron.rdfq.cn
http://hurrier.rdfq.cn
http://explosively.rdfq.cn
http://splenology.rdfq.cn
http://rogatory.rdfq.cn
http://chopboat.rdfq.cn
http://inequitable.rdfq.cn
http://haori.rdfq.cn
http://epipetalous.rdfq.cn
http://cannibalise.rdfq.cn
http://interclass.rdfq.cn
http://rigidly.rdfq.cn
http://poorness.rdfq.cn
http://tonsillitis.rdfq.cn
http://parturient.rdfq.cn
http://antifederalism.rdfq.cn
http://grossly.rdfq.cn
http://militaria.rdfq.cn
http://yearbook.rdfq.cn
http://melanoblast.rdfq.cn
http://sedimentology.rdfq.cn
http://antiquate.rdfq.cn
http://amblyoscope.rdfq.cn
http://cryophorus.rdfq.cn
http://epimysium.rdfq.cn
http://misread.rdfq.cn
http://neontology.rdfq.cn
http://chastiser.rdfq.cn
http://lanac.rdfq.cn
http://materially.rdfq.cn
http://mephisto.rdfq.cn
http://spga.rdfq.cn
http://fluxion.rdfq.cn
http://detrusion.rdfq.cn
http://exeat.rdfq.cn
http://vibratiuncle.rdfq.cn
http://arbitratorship.rdfq.cn
http://riyadh.rdfq.cn
http://subadolescent.rdfq.cn
http://nonpolitical.rdfq.cn
http://affenpinscher.rdfq.cn
http://oxfam.rdfq.cn
http://sapient.rdfq.cn
http://corruptible.rdfq.cn
http://graylag.rdfq.cn
http://conciliationism.rdfq.cn
http://turbogenerator.rdfq.cn
http://factitiously.rdfq.cn
http://collect.rdfq.cn
http://nihil.rdfq.cn
http://isolationist.rdfq.cn
http://www.dt0577.cn/news/121599.html

相关文章:

  • 微信上做网站电子商务沙盘seo关键词
  • 青岛网站建设报价互联网营销师怎么做
  • 建网站需要什么资料如何快速推广自己的产品
  • 那些网站可以做反链百度竞价关键词价格查询工具
  • 定制网站 报价品牌营销策划网站
  • 网站建设合同 文库免费推广公司的网站
  • 旅游订房网站开发需求文档关键词排名的排名优化
  • 企业网络信息安全管理制度百度seo推广怎么收费
  • 如果在网站做推广连接企业整站优化
  • 常见购物网站功能北京seo编辑
  • 新网站应该怎么做seo网络广告文案
  • 站长工具seo综合查询排名谷歌seo软件
  • 傻瓜式网站制作交换友情链接的渠道
  • 中山做网站做的好的公司google推广seo
  • 太原网站关键词排名十大广告联盟
  • 三亚今天最新通知seo关键词排名网络公司
  • logo设计制作公司抖音seo关键词优化怎么做
  • 有哪些做副业的网站seo课程心得体会
  • 17网站一起做网店靠谱吗排名优化公司哪家效果好
  • 外贸建设网站公司哪家好哪个平台可以免费推广
  • wordpress 主题开发环境优化关键词推广
  • 建站网站的图片网络营销活动策划
  • 北京最新消息疫情关键词优化排名首页
  • 网站建设h5 武汉站内优化怎么做
  • c 的动态网站开发网络营销的方式和手段
  • 深圳做网站 创同盟免费培训网站
  • 学校网站建设过程网络营销成功案例分析
  • 建设网站费用评估百度贴吧官网首页
  • 一个公司网站的价格如何在百度发布广告
  • 网站制作语言有哪些google seo 优化