Home Features Docs Blog Support GitHub

What can I do in Java code? What I can't?

I am looking for a way to port my financial Java Android app to iOS.
Does MOE support only easy Java code?
Or can I use my Java code as is. That is to say activities, fragments, alert dialogs, threads, callbacks, interfaces, file utilities, singltons and so on?
How about RxJava2 and Picasso?
Which type of Java code I can’t use?
Thank you.

With the newest MOE (1.9.0) you can use java api’s up to java ~11 (it may be that some java 8+ api’s are accidentally missing). In general you can’t use android specific api like fragments etc. There are some android api’s that are available, but they may be unavailable in future releases.
So in general, you should be able to use everything that is not android dependent.

How I use MOE is the following:
I had my android app and refactored everything that was plain java into a “common” plain java module. Than both modules, ios and android, depended on the common module and implemented the ui/platform dependent stuff. The same way are also most samples constructed.

About ios module: MOE has bindings for the iOS API’s that you need to use to do ios specific stuff (like ui). So when searching for ios tutorials you will find ObjC or Swift code and you can translate that code to java code with the bindings provided by moe.

For some examples you can take also a look at the samples: https://github.com/multi-os-engine/moe-samples-java/.

Hope this helps a bit!

1 Like

Thank you. I will try after I get a Mac machine.

I could not understand the following.
Why we need Common java module
if our activities, fragments and other code works as is on iOS build.
Why we don’t use entire Android source?

Android API’s like fragments/activities etc. wont work on iOS. This stuff needs to be reimplemented in the iOS module with iOS specific api’s.

1 Like

If Mac OS does not have fragments I can transform fragments to activities.
I hope there is MOE example with multiple activities or document.
And I hope that MVP app model is just right for Multi-OS engine.

Activities are also only android related.
What MOE enables you to do is to 1. use Java code on iOS and 2. call iOS ObjC api methods from java.
So you need to redo the ui with iOS specific apis. For that you might want to look at some iOS docs/tutorials.
This e.g. gives a introduction to viewcontroller: https://developer.apple.com/library/archive/featuredarticles/ViewControllerPGforiPhoneOS/index.html
You need to translate the code shown in the tutorial to java code, with the iOS bindings. How to work with the bindings is explained in the docs/samples.
https://moe.noisyfox.io/doc/multi-os-engine/4_create_ui/2_with_storyboard/with_storyboard.html
A example that works with view controllers is e.g. https://github.com/multi-os-engine/moe-samples-java/tree/moe-master/TheElements/

1 Like

Thank you for valuable info.