How to enhance a class in Codename One API - codenameone

I'm looking to add functionality to the built in Java SDK classes beyond the CLDC 1.1 standard which is where the API seems to be compatible with. Specifically looking to implement StringBuffer#replace(...)
What is the best way to go about this?
Thanks

cldc1.1 is a very old standard. Codename One supports far more than what that standard had but retained the filename due to legacy issues.
There is a guide on how to use the Codename One source and contribute it back to the git repository: http://codenameone.com/blog/how-to-use-the-codename-one-sources.html
However, the main issue is the need to fix this for all OS's which is pretty challenging.
To just fix the stubs for the method to appear to compile you can change the project here. However, this will only work for targets where the method is already there (Android, JavaSE etc.).
You will then need to make sure there is an implementation for all other targets:
For Windows you will need to fix the ikvm target and fork, for iOS you will need to fix the code in the JavaAPI directory under the VM directory for JavaScript you will need to contribute your changes to TeaVM if required.
For older platforms you will need to implement your changes into the retroweaver support although this might not be as relevant.

Related

Current support status of WebRTC in Codename One and AntMedia usage

Is there any information, updates, or documentation regarding Codename One's WebRTC support? There was a mention of it months ago in this comment on Stack Overflow (AntMedia Native Interface issues), but then I haven't heard anything more about it.
For the time being, I'm supporting live streaming on AntMedia via native interfaces that do live streaming with RMTP, as on my own I couldn't find a way to support WebRTC in Codename One. Unfortunately I realized just today that the RMTP support on Android doesn't work anymore (I don't know why, in the past months it worked)... anyway I've always considered RMTP as a temporary workaround, maybe this trouble is a good opportunity to switch to WebRTC.
I've seen that Steve has quietly created this cn1lib, which has not been announced (maybe because the work is not yet finished?) nor is it present among the extensions that can be installed via Codename One's Control Center:
https://github.com/shannah/CN1WebRTC
I found the documentation here:
https://shannah.github.io/CN1WebRTC/javadoc/
but comparing this javadoc with the documentation provided by AntMedia I just don't understand what I have to do, as AntMedia provides its own SDKs for Android and iOS, provides documentation to use them, but I don't understand how I can use in their place the cn1lib made by Steve. Obviously porting their SDKs is not easy, otherwise I would have already done it as the first option. In any case, the AntMedia server should be independent from the SDKs used, as it should use standard protocols, if I understand correctly.
Specifically, I have a server running AntMedia Enterprise Edition 2.1.0, whose documentation on WebRTC support is here:
https://github.com/ant-media/Ant-Media-Server/wiki
Thank you
I haven't used AntMedia Server, so my following comment is based on 10 minutes looking through their documentation.
It looks like they provide their own API that is distinct from the standard WebRTC APIs. The Codename One WebRTC lib is built on the standard WebRTC APIs. I think that the best route, if you want to use AntMediaServer's APIs is to create native interface wrappers for it.
It is also possible and likely that you can just use the Ant Media Server and then use the standard WebRTC API to connect to it. If this is the case, then you would be able to use the cn1lib with it. However, their documentation only seems to show how to use their custom API for the client.

is there a way to add patch version in CN1 version number

To my knowledge CN1 does not allow to keep patch version in the Version number. Please advise if there is a way I can do it.
Thanks
Codename One only supports decimals because Android and iOS handle versioning very differently. It's really hard to create common code that works everywhere that's still easy to use.
As a workaround you can use the build hint ios.bundleVersion=1.1.1. Notice that this overrides the version value you set in the UI.

How to include using Smartwatches in an app written with Codename One?

My company recently came up with an idea to include using smartwatches with the app I wrote using codename one.
Is this possible? If yes, which libraries do I need?
We are evaluating the possibility of smartwatch support, this depends on customer demand.
We currently have a major enterprise prospect that has expressed interest in this but hasn't signed up. If your company is serious about this please contact us directly.
Assuming we don't go that route or you need something immediately this depends on your supported platform, you would need to use native interfaces for most functionality. In Android notifications (which we support) should work for Android wear. In iOS we are transitioning to the new xcode 7.x which should support smartwatches too but I'm not sure what would need doing.

Create a library with codenameone to use on iOs and android

I was wondering if it is possible to create a library with codenameone that can be used in a native iOs/Android/... App. This library should contain the business-logic and the rest of the app should be implemented native.
Is thought this isn't possible, but the technical advisor of a client insists that this is possible.
I misread the original question, you are correct its impossible to do this and impractical to do this since the size of the library will be too big. If you want to create a library for iOS with Java the best approach would probably be J2Obj-C which was designed specifically for that purpose: https://code.google.com/p/j2objc/
Originally I had referenced these which allow you to create library projects for use with Codename One which might be the source of the confusion:
http://www.codenameone.com/3/post/2013/07/jaring-and-libraries.html
http://www.codenameone.com/cn1libs.html

How cross-platform is Monotouch/Mono for Android development?

I am a python programmer looking to make my first mobile app. I'd like to make make an app for both iOS and Android that looks and feels native. I thought I'd start with a simple iPhone app, just to see how everyting works. Mono seems like the obvious solution. However, I was surprised to find that almost all of the example Monotouch code I found, as well as the answers here on Stackoverflow, relied heavily on the IOS frameworks, essentially making the code not cross-platform at all. For example, I was looking into using a timer. All the examples I read use NSTimer. Surely this is possible to do in C# itself so that that part is cross platform? But then, why do all these people use NSTimer?
So, my question is, how cross platform is Mono development for IOS/Android? Is it still worth considering for smallish apps, or only for very large apps with lots of business logic?
Your question is too general. I'll answer it for two scenarios:
Specific examples
If you are looking for how do create timers, create arrays, traverse lists, then why not just look for regular .NET examples and compile this into a single class library that can be in both projects.
Sharing code as a whole
If you just mean in general sharing of code between the two platforms, you should look at frameworks that already have the templates and examples created for you. Two such patterns are http://www.monocross.net/ (MVC) and mvvmcross (MVVM). This can help you architect your project from the beginning to support cross-platform development (iOS, Droid, Wp7, desktop, etc).
There are timers, arrays, and strings in the .NET Base Class Library. As you have seen, there are some in the Cocoa library that MonoTouch wraps. For example you have your regular run of the mill string in .NET, but in monotouch you also have the option of NSString. I think to answer your question, the reason people may use the iOS specific types sometimes, is either because they weren't trying to make that code cross-platform and it was a matter of preference, or they had to do something specifically that required the use of that type which wouldn't be the case for everyone.
Mono's purpose isn't just to help with cross-platform development. I come from a C#/.NET background so even if I was building an app with one screen and two buttons, I would use MonoTouch because I would rather use C# with the .NET BCL than Obj-C. But that is my own personal choice and enough of a deciding factor, for me.
EDIT
I added the links.
I think the key point is that in order to use Mono and NOT use platform specific types etc like NSSTring you need a platform specific wrapper (abstraction layer) that lets you write code that only uses Mono types.
i.e. You are asking about using Mono but what you actually need are MonoTouch and MonoDroid (the frameworks referenced by #valdetero, depend on having those wrappers underpinning them).

Resources