Monday, 4 January 2021

Android JNI Example 1

 Hi Guys !!! Hope all is well

I am going to show Android JNI example 1 using Android Studio.

In my previous blog on JNI and NDK, I have written below thread.

https://saurabhsharma123k.blogspot.com/2017/02/generate-so-file-by-using-ndk-and-use.html

https://saurabhsharma123k.blogspot.com/2017/07/exception-handling-in-jni-and-throwing.html

In this example, We can discuss below topic. 
  • Received String from Native layer to Upper layer (App)
  • Send String from Application to native layer
  • Received String Array from Native to Upper layer

The example code is on my github page

https://github.com/Saurabh-12/AndroidJNI

In this example, I am using Android Studio (version 4.x) to write both java and native code. Unlike my previous example where I use NDK tool to generate shared library(.so) file and then use that file inside Android application. 

Thanks to latest version of Android Studio(AS) to incorporate CMake, so that we can develop java native application seamlessly.

Note :- 1. For Framework developer(Android System programing) , they can leverage this A.S. feature to develop and test before pushing there native app in Android BSP.

2. App package detail (java and cpp file), gradle build details and other AS stuff directly download full source code from my github page and import it in AS.

You can see code snippet for above example on my github page. So i am not doing it here copy paste.







Thanks
Saurabh 
Happy Coding !!!

2 comments:

  1. Really I enjoy your site with effective and useful information. It is included very nice post with a lot of our resources.thanks for share. i enjoy this post.
    Adwords Agency

    ReplyDelete


  2. makes it simple to use for even the most beginner client. More Info

    ReplyDelete

Build a Custom Kernel Module for Android

Hi Guys!!!Hope you are doing well !!!. Today I will describe how you can write a custom kernel module(Hello world) for Android and load it a...