dot42


Using native C libraries in dot42


Is it possible to use a native C/C++ library with dot42? If so are there examples of how to do this? If not is this a planned feature?
Given the JNI implementation a native method such as the following:
#include <string.h>
#include <jni.h>
jstring Java_dllImportTest_MainActivity_Foo( JNIEnv* env, jobject thiz)
{
return (*env)->NewStringUTF(env, "Hello from dot42 JNI !");
}
The JNI tooling will compile this to a native library and put this in e.g. libs\armeabi.
Copy the libs folder to the root of your dot42 project and include the .so in your project. Next set the build action to NativeCodeLibrary:
Next declare the native method in your C# code using the DllImport attribute and call it like this:
using System;
using System.Runtime.InteropServices;
using Android.App;
using Android.Os;
using Android.Widget;
using Dot42;
using Dot42.Manifest;
[assembly: Application("DllImportTest")]
namespace DllImportTest
{
[Activity(Label ="DllImport MainActivity")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle savedInstance)
{
base.OnCreate(savedInstance);
SetContentView(R.Layouts.MainActivityLayout);
var textView = FindViewById<TextView>(R.Ids.label);
textView.Text = Foo();
}
[DllImport("dllImportTest")]
public static extern string Foo();
}
}
The loadLibrary call is generated by the dot42 compiler.

Related Links

Dot42 gives “object reference not set to an instance of an object” when inputting registration key
Get declared methods in interface
Referencing libraries from other solution
Emulator for Deploying and Debugging
Using native C libraries in dot42
Using SQLite with dot42
How to make a SOAP call with dot42?
How to handle “An Item with the same key has already been added” when adding .jar to dot42 project
How to unsubscribe an event with dot42
WaitOne() timeout parameter lost?
HOw do you uninstall Dot42
On every button click data is added to listview but in an unexpected manner . Data is repeated in the listview
Asynchronous SQLite sample with dot42?
dot42 - http POST request with parameters
Sharing code between a dot42 project and a mono desktop project

Categories

HOME
delphi-7
android-studio-2.2
jmx
toolbox
package
rendering
gembox-spreadsheet
babeljs
hpc
missing-data
joomla3.0
accessibility
dkim
openpyxl
why3
naivebayes
symmetricds
plink
magnetic-cards
html5-appcache
breadth-first-search
articulate-storyline
dapper-extensions
angularjs-components
flooding
amazon-quicksight
android-things
errbot
sqsh
google-earth
hibernate-validator
r-grid
memory-address
papaparse
classcastexception
slacktextviewcontroller
servicestack-text
searchkit
openerp-7
git-rewrite-history
release
odroid
css-position
opensmpp
wmp
bindingnavigator
knime
x++
jboss-4.2.x
bbpress
google-photos
renaming
sandcastle
juice-ui
gets
rocks
pytables
custom-lists
winusb
iotivity
watch-os-2
google-query-language
phpwebsocket
design-principles
asyncdisplaykit
highland.js
jnlua
themoviedb-api
intel-c++
sql-server-data-tools
omnifaces
aspectj-maven-plugin
jquery-forms-plugin
code-documentation
beatsmusic
viewer
wcm
rmysql
mobility
gae-quotas
getopt
android-audiorecord
openargs
solace-mq
unit-of-work
android-loadermanager
panda3d
pstack
veracity
adobe-media-server
floating-point-exceptions
virtualpathprovider
node-redis
procedures
exponentiation
drawtobitmap
uideviceorientation
cfwindow
glui
mathematical-notation
escrow

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App