Can a fully native Android app call Java? - java

Good day.
It is possible to change for example native-plasma, which is a fully native Android app with only C++ and no Java or Kotlin, to be able to call Java?
I have used native-plasma as a base for an application, and now I need to call into third-party libraries, which they provided as Java, of course. But I cannot seem to find a way to now import their libraries and use their classes.
Thanks, help is appreciated.

Related

Using native code from C language in Java for Programming Microcontroller

I have a source code library from Renesas for their Co2 sensor. The source code library is completely written in C language and a static library (with .a extension) of it is given for the Co2 sensor which was helpful for me to use it in any microcontroller that uses C/C++ language. Even there are a lot of examples of it.
So, I have a microcontroller called DPM5050 which runs in Java programming language. Therefore, I came to know, that it is possible to use the native code in JAVA using JNI (Java Native Interface). I also came to know that to use native source code in Java, I need a dynamic link library. But I only have a static library which is provided by the Renesas.
My question is how can I do that using a static library that was given by Renesas?
Can I able to change the static library to the dynamic link library by myself without contacting Renesas?
And how to implement this in Java using JNI to use the native source code library provided by the Renesas?
Since I just came to know about this JNI technology to use native
source code in Java. So, I would also like to ask you to give me
suggestions or opinions on this topic. And I am also looking for some
good documentation with examples or tutorials or guidance to proceed
further.
Right now, I am reading Java APIs, Extensions and Libraries: With JavaFX, JDBC, jmod, jlink, Networking, and the Process API - by Kishori Sharan's book in Chapter 7 of this book they have some details about JNI.
I am looking forward to your responses. Thanks in advance.
Kind Regards,
Mustaq.

Objective C/Android Java calling Xamarin code

We have Objective C and Andoid Java applications and would like to create a component using C# and Xamarin that would interact.
Is there a way these technologies can communicate with each other (Objective C <-> Xamarin and Android Java <-> Xamarin).
Not sure how you do this but searching here it may be possible to create a static library in Objective C/Java that can be called from Xamarin.
From there I understand that you can start the Objective C/Java app from the Xamarin Main method and afterwards can call other static library methods.
Ideally we would like to call from the Objective C/Java app to Xamarin.
According to Miguel in this post it is possible but are there any examples anywhere.
Hope the explanation makes sense.
Thanks
From the wording of your question, this is not possible.
Xamarin does offer the ability to create 'bindings' between C# and Objective C/Java static libraries and has a section on the Developer documentation on doing so (Objective C Bindings or Java Wrappers).
The key part is that this is for static libraries and not for general application functionality i.e. user interactions.
You will need to weigh up the benefit between migrating the disparate projects to a shared Xamarin solution whereby you will enjoy the code sharing (especially with the Xamarin Forms offering) or simply writing the functionality into separate libraries for the different platforms.
Good luck

How to implement equalizer in Android 2.1?

I know this has been asked earlier but I was not able to find much needed information.
I have implemented equalizer in 2.3.
But I want to implement it it in 2.1
There are 2 ways I came across:
Either import the java library code from 2.3 to 2.1. But I do not have much hope with this.
Or, use JNI & Android NDK and use some out of box C/C++ libraries. (Please suggest are there any libraries available)
If any other solution is viable then please suggest.
As is mentioned in How to implement Equalizer in Android2.1? you will need to implement your own signal processing in native code with JNI

OpenCV on Android, when do I need native code?

I'm looking into using OpenCV for an Android application and am running into some problems compiling the samples which use Native OpenCV.
So, my question is:
When using OpenCV, when will I need to use Native OpenCV code? Can I get by without using it (as in Tutorial 1 within the samples)?
Apologies for the vague question, I can be more specific if that would help.
Thanks for any help in advance.
It depends on what you want to do, really. Native calls are very expensive in terms of speed, so if this is relevant for your application, you should reduce them to the minimum possible. Most of the Android OpenCV libraries rely on native calls, so going native or using OpenCV Java calls should not give a relevant increase in terms of performance time. But there is nothing like testing it.
You would also like to use native code if you already have C/C++ OpenCV implemented code. That would save you some time re-writing it in Java. You should also use native code, if the functions you want weren't already ported to Android (it is up to 42%, currently).

Porting blackberry application code in to Android platform

I have an Blackberry library written using JAVA as well Blackberry(RIM) specific API's. I would like to port the same library in to Android platform without making any code changes and make it run.
Here i am looking for the best way to achieve it
Any cross compiler/cross framework is available for making my Blackberry run on Android platform.Thinking this would make my job easy ;)
Please share your inputs on this.
Thanks in advance.
You can't do that. AFAIK, Blackberry uses J2ME technologies(can be wrong here). Android system is built in absolutely other principles. You have got to learn android in order to understand how to build GUI, how to process with background tasks and where you store your data. Sorry.
Start with application fundamentals.
If porting was that easy, a lot of developer would be out of work.
You will not have to rewrite the whole application, but surely there must be quite a few changes done. If you have a clean design, you might be able to reuse a lot of code as it is. Otherwise it will get more complicated. For the RIM API, it might be a good idea to write interface-classes first ("RIMXyz implements IntrfXyz"), that have all the function-call that you use of the RIM-API. Then you can write the Android API classes using "AndrXyz implements IntrfXyz". Put the RIM-dependend stuff in a separate external lib, and do the same with the android-dependent stuff. Then you can have a RIM-prj and an Android-prj, each only linking to the dependent classes and the reusable classes. That way you could structure you porting project quite nicely.
Also the "top" end of the application surely has to change, because you have to use the "activity"-class in Android to get anything running. Those are the two aspects I see.
I hope this is understandable, a bit hard to put it in a few words...
I have started a cross-platform project for Android/Java applet, and this is how I've done it. It works. ;-)
You cannot do this without some code rewrite. If you can tell us more about the classes in the RIM API that you are using, you might get some specific answers as to what classes from the Android API to use.
You should find similar functions in android api to replace RIM API invocations and refactor your code using for example Abstract Factory design pattern. (http://sourcemaking.com/design_patterns/abstract_factory)

Categories

Resources