资源描述:
《JNI Example on android》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、JNIExamplesforAndroidJurijSmakovjurij@wooyd.orgApril25,2009Contents1Licence12Introduction13Javainterface24Nativelibraryimplementation44.1Headersandglobalvariables.....................54.2CallingJavafunctionsfromJavaandnativethreads.......64.3Implementationofothernative
2、functions..............94.4TheJNIOnLoad()functionimplementation............115Buildingthenativelibrary146UsingnativefunctionsinJavacode147Unresolvedissuesandbugs181April25,2009JNIExample.nw11LicenceThisdocumentandthecodegeneratedfromitaresubjecttothefollowinglicence:Co
3、pyright(C)2009JurijSmakovPermissionisherebygranted,freeofcharge,toanypersonobtainingacopyofthissoftwareandassociateddocumentationfiles(the"Software"),todealintheSoftwarewithoutrestriction,includingwithoutlimitationtherightstouse,copy,modify,merge,publi
4、sh,distribute,sublicense,and/orsellcopiesoftheSoftware,andtopermitpersonstowhomtheSoftwareisfurnishedtodoso,subjecttothefollowingconditions:TheabovecopyrightnoticeandthispermissionnoticeshallbeincludedinallcopiesorsubstantialportionsoftheSoftware.THESOFTWAREISPROVIDED"
5、ASIS",WITHOUTWARRANTYOFANYKIND,EXPRESSORIMPLIED,INCLUDINGBUTNOTLIMITEDTOTHEWARRANTIESOFMERCHANTABILITY,FITNESSFORAPARTICULARPURPOSEANDNONINFRINGEMENT.INNOEVENTSHALLTHEAUTHORSORCOPYRIGHTHOLDERSBELIABLEFORANYCLAIM,DAMAGESOROTHERLIABILITY,WHETHERINANACTIONOFCONTRACT,TORTO
6、ROTHERWISE,ARISINGFROM,OUTOFORINCONNECTIONWITHTHESOFTWAREORTHEUSEOROTHERDEALINGSINTHESOFTWARE.2IntroductionWhileJNIisaprettyexcitingwaytogreatlyextendAndroidfunctionalityandportexistingsoftwaretoit,todatethereisnotalotofdetaileddocumentationonhowtocreatethenativelibrar
7、iesandinterfacewiththemfromtheAndroid'sJavaVirtualMachine(JVM).Thisdocumentaimsatllingthisgap,bypro-vidingacomprehensiveexampleofcreatinganativeJNIlibrary,andusingitfromJava.Thisdocumenthasbeengeneratedfromsourceusingnoweb,aliteratepro-grammingtool.TheJNIExample.nwist
8、hesourceinnowebformat.Itcanbeusedtogeneratethedocumentoutputinavarietyofformats(forexample,PDF),aswellasgeneratetheJN