Use both JavaFx + Acitivity on Android - android

So, in my project, I'm merging a few pieces of code, written earlier, into one application. I have :
some Android activities (i.e. Maps activity, login activity)
some JavaFX controls / forms (used before on Windows client).
Now, I would like to reuse those JavaFX forms on my Android application, but still be able to load my previous Android activities on some button click or sth.
Is there any way, this could be achieved ? Greetings

If you want to merge JavaFX and Android projects, you should have a look at the JavaFXPorts project.
You will be developing a JavaFX project that could be deployed both in desktop and on mobile platforms.
For that, you just need to include one single plugin on your build.gradle:
apply plugin: 'org.javafxports.jfxmobile'
For starters, you may consider using Gluon's plugin for NetBeans, that will create for you a JavaFX project where you can add your sources: you could add your existing JavaFX sources to the Main folder, and you could add also your Android activities to the Android folder.
You will have to adapt the Android activities so they run on the JavaFX thread with FXActivity.getInstance().
Have a look at this post with a sample of that.
You may also have a look at Gluon Charm Down library, that can be added to your project, to interact with native services, like GPS.
Keep in mind Android runs Dalvik VM, so you won't be able to use Java 8 new features (streams).

Android SDK doesn't come with any Java gui library. If it is mandatory for you to reuse the same form (i.e. refactoring will take weeks), Jose answer is probably what you need.
But if it's not mandatory (i.e. you just want to avoid 1 or 2 hours of writing code), I'd suggest you just re-code it using Android UI classes, as it will make it easier to maintain and scale in the future.

Related

How to use Kotlin with React Native in Android Studio?

I want to make an android app using Kotlin for the back end and Android Studio. For the front end, I understand that React Native would be a powerful choice, however I cannot figure out how to add ReactN to my Kotlin project.
I also tried creating a project in ReactN and then adding Kotlin: installed nodejs, npm and create-react-native-app, made the project. Then I tried opening it in Android Studio, but I wasn't getting any options to actually compile and run the project. So another question would be: can you work on ReactN projects in Android Studio or not?
If you could give me some resources on how exactly to do this, or if you can walk me through it step by step, it would be very helpful. I want to mention that I've never developed for Android or Web before (I'm mentioning about Web because I cannot rely on any Reactjs knowledge from Web dev).
React Native is whole framework, for front and back end, and have nothing to do with Kotlin (well, some Kotlin snippets may be integrated into RN app, thats all). RN projects are in fact multiplatform web/js based apps and Kotlin is used for writing pure Android apps, so this isn't a front/back end separation in here, these are just different approaches to development. Mixing both, while possible, makes no sense in most cases

NativeScript : Use platform specific native library without a multi-platform plugin?

We're trying to use ArcGIS's Android Runtime SDK in NativeScript (it has no nativescript plugin) but we have accessed that rewriting the whole library as a multi-platform plugin would take too much time.
My question is, how can we utilize the native library directly but only the android version of it?
This is the library: https://developers.arcgis.com/android/latest/api-reference/reference/packages.html
Also, is it possible to use it without a custom UI plugin? I don't understand how to add the mapView to the app .xml
For example, in their AndroidStudio tutorial they mention the following steps and I'm not sure how to translate them to NativeScript
Source : https://developers.arcgis.com/android/latest/guide/develop-your-first-map-app.htm
I'm not quite sure what you mean by re-writing the whole library, you never have to do that.
Plugins are being written to wrap the native library with simple user friendly JS api / methods, it necessarily need not to be cross (or multi) platform either.
You may even directly access any third party library within your project as soon you mark them as dependency in your app gradle file.
Here is how you access native apis.
For instance if you want to create an instance of LocatorTask, this should work once you add the library as dependency in your NativeScript project.
const locatorTask = com.esri.arcgisruntime.tasks.geocode.LocatorTask("URI_HERE");
locatorTask.loadAsync();

Creating android application without Android framework

In Android Stack 4th Layer is android Framework which uses JAVA,Kotlin. If I am correct than all applications are made from this framework.
Is there some other non JVM-Language based framework from which I can made Android Apps ?
I tried QT, But It also creates some java files and uses android Framework. Is it even possible to make Android app WITHOUT EVEN ANY PRESENCE OF JAVA ?
If your objective is to simply not write in a JVM language, you are welcome to use C/C++ with the NDK, using NativeActivity as your entry point.
If your objective is to avoid the framework classes entirely, you are welcome to build your own fork of Android that contains your own code as native Linux daemons, launched by init scripts or something.
If your objective is to ship an app on the Play Store or through similar channels that avoids the framework classes entirely, AFAIK there is no option for that.
You can not create an android application without using android framework. At least, for launching your application you will have to use framework functions from "android.os" package.

Insert unity as in a subview in android and plug in

I have to build an android app in which I have to integrate unity player with an existing android application. I need to get values from a sensor and animate the gameObject in unity. Should I make a plugin using ndk or jni? Please help. I'm new to this. I have read the docs but I am confused.
You can choose to build an Android Studio project instead of an APK. To do this, select the "Google Android Project" checkbox from the android build settings.
This will give you a project with a main activity which is a UnityPlayerActivity. You can add/remove activities, views and do anything you want with the project. You should also be able to move the contents to another project and merge them. The important thing here is to keep all the libraries and resources Unity builds intact. This should all feel natural if you're familiar with Android Studio.
To pass data to/from Unity, you can use the AndroidJava* classes, which essentially allow you to call any Java code (from the OS libraries or your app package) as if you were using reflection API.

How to keep two versions of the same android app?

It's quite often that we see two versions of an android app: a paid version and a free version. I'm also developing an app that would like to release two versions. What is the best way to do this? Creating two projects and copying files in between does not seem to be the best way in my mind.
Use Library Project, as the official dev guide suggested:
If you have source code and resources that are common to multiple Android projects, you can move them to a library project so that it is easier to maintain across applications and versions. Here are some common scenarios in which you could make use of library projects:
If you are developing multiple related applications that use some of the same components, you move the redundant components out of their respective application projects and create a single, reuseable set of the same components in a library project.
If you are creating an application that exists in both free and paid versions. You move the part of the application that is common to both versions into a library project. The two dependent projects, with their different package names, will reference the library project and provide only the difference between the two application versions.
Update: This method is really only good for compiling with Eclipse, since Android Studio supports build flavors which can achieve exactly this.
While #yorkw's and #Nate's answers are both good, this is the method I use due to its simplicity. From the article:
com.example.myapp – Android Project Library - This is where my ENTIRE app lives. All the functionality for the FULL and LITE versions.
com.example.myapp.full - Android Application Project - This is a shell that contains graphics and resources needed for the full version only. Basically it’s a super lightweight shell.
com.example.myapp.lite - Android Application Project – This is another shell that contains nothing but graphics and resources needed for the lite version. Again, its a super lightweight shell.
I also keep a static variable IS_PRO in a library class which is set when the app launches. This should be used only for notifications, alerts, and so on (such as asking the user to upgrade to pro).
However, this method has one drawback: you must clean and rebuild any time the library or its resources are modified. Also be sure to read this post on sharing resources between a project and a library.
I would call this a FORK in development. Start a new App development, but have your common code coming from a common file location. Make your free based edits to the forked code, and try your best to keep that code completely separate.
I actually did this on an iPhone based app, I have a free version and 2 different payed versions (a single player only and a multi-player). I would do it the same way on Android.
U can use git for example.
Create branch "app_with_ads", and master will be your "paid" version.
Develop in master and merge periodically to another.
before publish u probably will have to change app package, or something else in Android\ Manifest.xml
Here's a little blog tutorial about doing this.
Basically a howto for building a Full and Lite version of the same app, using a library project to accomplish code reuse between the two versions.

Categories

Resources