Developing a Java Cross platform library (mobile and web) - android

There are so many cross platform libraries that I am kinda lost to get an answer to a very basic java question.
I have a java library that works well on Android. It does not use any android specific functionality and also builds on the standard java sdk. This library uses sockets (plain simple Socket, ServerSocket kinda architecture) to communicate between the library and a server hosted (may be on a ec2 or some virtual public server).
Now my question is, can other developers import my java library (built using java sdk) to a application that uses html/css for User Interface, package all of this into a mobile application for iPhone (use native iPhone packaging, and a WebView to launch) ? Also can I ship this library so other software developers can build a web application to work on desktops and cross browser's ?
Some questions on stackoverflow are close to what I am looking for, but not quite there.
Developing Mobile Apps for Multiple Platforms (without a cross-platform framework!)
Will a webserver be able to use my library that connects to the server using sockets ?
And will every client that connects to this webserver create a new instance of my library ?

If you library doesn't use any dependencies on either Android or any other library, another developer can use it pretty much anywhere they want. Although keep in mind that platforms like EC2 may have a preferred way of using communication. (I'm no expert on EC2, so you'll have to see what they use.)
So I guess it's better to abstract out that socket functionality for good.
I don't think you can use a Java library in iPhone. iOS terms of use clearly states that you cannot use a compiler or interpreter on the device other than the one given in the SDK and the webkit javaScript engine in Safari. So there's no way your Java code is going to run on iPhone (without jail-breaking.)
I don't understand the question about webView. Do you mean navigating to a site that is powered by your library ? If yes, then yes as long as you keep it in the boundaries of Safari. (no Flash, no Java Applet .etc.)
Will a webserver be able to use my library that connects to the server
using sockets ?
For the most part, yes. But as I said, the platform may not allow raw connections, so it's good to abstract it out.
And will every client that connects to this webserver create a new
instance of my library ?
This depends on the design of your library and its public APIs.
Hope this helps.

Related

How to create Android Web UI - remote app management

I have an application that runs on Android phone. I would like to add web ui like let's say torrent applications. I would like to manage my application from browser using my laptop, or another phone located on a different side of the planet ;)
What is the easiest way to run a web server inside app, and host a management web app? Is it possible to run nodejs/php server inside application and communicate with hosted web app?
Should be possible, because ttorrent and x-plore have such feature.
Thanks for any clues and advices.
I did several in-app web server projects. nanohttpd and golang are used in my projects.
Nanohttpd is wrote in pure Android SDK compatible Java. You can call any Android SDK API, with no need of RPC or language binding. But nanohttpd has little supports to develop web API. It's not a good choice if you have lots of APIs between javascript and the in-app server, but good if you need invoke Android SDK APIs in the in-app server.
golang supports Android(ARM Linux) well. The good parts are:
static link. you just need coding and build, everything will in one shared library file, you can ease use the library in your Android project
powerful APIs in standard library to develop a web server and web client. Great performance because of golang's async I/O and thread model
gomobile provide a tool to generate RPC wrapper for golang-java inter-operation. golang-c(jni)-java wrapper will also work but I not found a tool to generate the binding, writing bindings is boring.

MVVMCross (WP8, Android, iPhone) + Azure Mobile Service

I need to create an app for WP8, Android and iPhone that uses the Azure Mobile Service. I am really impressed by the MvvmCross project so I really want to use it.
Before starting I have some questions:
Can I add the AMS SDK to the .Core project and will it work for all platforms?
Is the a easy way to handle the login views for the authentication providers on the different platforms?
I am a little bit confused by the profiles, which one should I use?
I would really appreciate if anyone can answer my questions,
Michi
Can I add the AMS SDK to the .Core project and will it work for all platforms?
The Core project is a Portable Class Library.
If you want to use Azure Mobile Service SDK in it, it means you need to add it as a reference to the Core PCL, which means the AMS SDK needs to be a PCL also.
Further more, if you need it for all platforms (Windows Store, Phone, iOS, Android) this means the AMS PCL needs to have an implementation which works on all these platforms.
Looking to https://github.com/WindowsAzure/azure-mobile-services, it looks like the PCL is ony for Windows 8 and Windows Phone 8.
There is however a Xamarin component for Azure Mobile Services, but it's not a PCL (if you download it and check it, there's a separate DLL for Android and iOS):
http://components.xamarin.com/view/azure-mobile-services/
http://www.windowsazure.com/en-us/documentation/articles/partner-xamarin-mobile-services-ios-get-started/
If you want to have a portable functionality in the Core to be used by the view-models, what you can do is define an service interface like IMyAMSClientService in the Core and have it implemented on each platform (you implement MyAMSClientService on each platform, in the app project). You will need to think about a mechanism to handle the AMS functionality in an unified way.
Is the a easy way to handle the login views for the authentication
providers on the different platforms?
Like I said above, you can have something like an IMyAMSClientService in the Core. The actual implementation of it will be on each platform and it will do the calls to the AMS SDK.
I am a little bit confused by the profiles, which one should I use?
I assume you refer to PCL profiles?
You don't need to use anymore any hacks to get the Xamarin profiles available when you create a PCL. Did you try to create a PCL? The Xamarin profiles should be there. You need to have Xamarin installed though.

Maximal reuse: Webservice, Android client, Web Client, how?

I need to build a simple web service in Java, the context is Google Application Engine.
Two clients are needed as well: Android and Web Page, for browser.
I consider something like Restlet, and want to re-use from it Android and GWT clients.
Could, you, please, give me a hint, whether it is a good way to go?
Could you advice others?
In particular, I could not find, how this technology coexists with WSDL, and if
I am going to be able to use it?
Restlet Framework is mainly used to develop RESTful web services, even though in practice you can also issue and receive SOAP calls to bridge with older systems (no WSDL support though).
For help on GWT and Android client sides, see:
http://wiki.restlet.org/docs_2.1/13-restlet/21-restlet/318-restlet/303-restlet.html
It depends a lot on whether you wish to build cross platform as in phonegap or keep it simple as in mobilewebapp example provided in sample folder in gwt zip file you download.
The mobilewebapp sample does not access smartphone features but will be accessible by browser on any mobile. phonegap or similar frameworks like titanium,sencha provide api to access smartphone features.
Fore more information -
http://www.sapandiwakar.in/technical/api-research-study-iphone-and-android-applications/
Sencha Touch 2 native build vs wrapping Sencha Touch 2 in Phonegap
Creating a mobile app using Google App Engine and GWT?

WebSockets for Android AND iOS Apps

Is there a project that provides libraries for communication over WebSocket for both Android and iOS? I know jWebSocket, but it is pretty much dead, and does not provide a lib for iOS. I know Autobahn, but it too supports only Android. I also know SocketRocket, but that is only for iOS. Is there something that supports both, or two solutions that are 100% compatible with WebSocket?
Thanks!
iOS uses ObjectiveC and Android Java, so there can't be a library that provides building the same unmodified user source code for both platforms for the platform's native language. You could have that (in principle) using C. And of course JavaScript.
Apart from that regarding the wire protocol AutobahnAndroid and SocketRocket should be absolutely compatible, since both use the AutobahnTestsuite to test protocol compliance.
Above is for pure WebSocket. If you want to use higher level features of i.e. Autobahn like the Publish & Subscribe and RPC messaging patterns provided by WAMP, we plan to have a iOS version of Autobahn that adds those .. on top of SocketRocket. No need to reinvent a mature, robust WebSocket implementation on iOS.
Disclaimer: I am creator of Autobahn/WAMP.

Android reusing GWT RPC backend without AppEngine

I have been developing GWT application for a while and I'm trying to port my app to Android. I'm very new to Android but it seems that the ADT share many similarities with GWT so the learning curve might not be very steep.
There's what I read from GPE 2.4
Android and GWT clients that are capable of talking to the same App
Engine backend using the same RPC code and business logic.
It would be great to share the same backend which I spent a hell lot of effort in design and implementation. However, I'm not using AppEngine and impossible to switch to it either. I'm wondering if the Android app can still share the same RPC structure with GWT without using AppEngine. Thanks.
If you're still in need of a solution, check out GWT-SyncProxy (Disclaimer, I recently joined the project). I just put out a 0.4 release that has an Android Library that allows you to make GWT RPC calls from Android (or Java standalone apps using the regular library).
https://code.google.com/p/gwt-syncproxy/.
The library can utilize Android accounts if you do switch to GAE, but it's definitely not required.
You can try to use http-dispatch. It is the adapted gwt-dispatch framework which can be used on Android platform. Http-dispatch uses default binary serialization so it works from the box for many types of objects. Currently it is in alpha but you can try http://code.google.com/p/http-dispatch/

Categories

Resources