I have a web application to be hosted on android device. I am currently using the emulator available with android sdk. My application will serve both static as well as dynamic data. I am currently using jetty version 6.1.22. I wanted to ask what will be a better option to be used.
1. Jetty webserver with stripped off code.
2. I-Jetty.
My application uses following features-
ResourceHandler to serve static resources.
A Generic servlet to serve synchronous data requests.
An extension to CometServlet to serve asynchronous data requests.
I am looking forward to following criteria for comparison.
Application size. Size of apk which will contain the code.
Memory and CPU usage under a maximum load of 30 requests/sec. These are short bursts which occur very few times in app-life cycle. The average load would be approximately 5 requests/sec.
Ease of maintenance. Including important upgrades of Jetty in application.
Any other side-effects which I probably am missing out at.
I too have been searching for information on embedding the i-Jetty server in an application. Like the original poster, I need to serve both static and dynamic resources. I found the following post to be a helpful start:
http://puregeekjoy.blogspot.com/2011/06/running-embedded-jetty-in-android-app.html
I notice that in searching for answers about embedding a web server in an Android app that many responders, rather than providing a helpful answer, chide the original poster for wanting to do such a thing "in a phone". They then proceed to give all the reasons not to. There are more Android devices out there than just phones. My project involves just such a device. Thanks for all the helpful answers on this and other sites that guided me in my efforts. I hope the link I provided helps other searchers.
There are good reasons for embedding a web server in your app. May not be the best way but you have to do it when Android ties your hands. An example is when you want to decrypt video on the fly at runtime and use the media player to play it. Android media player does not allow me to feed it an in-memory stream as would come from a decryption pipe.
In this case, one solution (help me think of others please!) is to embed a web server that would serve up the stream - because Android does accept a stream from a URL!!
The other solution would be port some native library over and write a JNI interface to it. Too much work and unstable at best.
The point is, there are valid enough reasons out there.
It you need to decrypt video or serve content, you might consider just writing a simple web server yourself that can specifically handle your application's needs without any bloat. Adding an existing web server or web container might be more than you need. It very much depends on your application's needs though.
I have a web application to be hosted
on android device.
Why? It won't be usable, except maybe on a WiFi LAN. It won't be able to run terribly long, because services cannot run forever. Etc.
Whatever technical problem you think you're solving by using a Web server on Android can be better solved by other means.
I wanted to ask what will be a better
option to be used. 1. Jetty webserver
with stripped off code. 2. I-Jetty.
Arguably "neither", not only due to the technical issues, but that Greg Wilkins (creator of Jetty) does not like Android much. Of the two, though, i-jetty is at least regularly tested on Android.
Memory and CPU usage under a maximum
load of 30 requests/sec. These are
short bursts which occur very few
times in app-life cycle. The average
load would be approximately 5
requests/sec.
While running, battery life will suck, because you are going to keep the CPU and WiFi running all of the time to support the Web server, let alone the load.
Related
Disclaimer. I'm asking this on someone else's behalf and given that I know as much about Android development as penguins about flight, it may be clumsy. In such case, let me know and I'll remove it or try to reformulate.
I've created a web service that's reachable at the URL on the following form.
http://server/Blopp.svc/Store/value1/value2
The back-end part I've got covered but I'm worried about the front-end development. I've got a colleague that's making the app and he's got the rudimentary GUI done. However, in order not to do a lot of convoluted coding, he's heard that there's a certain library for making such URL calls.
What's the name of it? Is there certain other aspects to take into consideration or is there an (almost) standard one that everybody uses?
Please not that the app's functionality is at the moment limited to providing the web service with data. All the logic and presentation is done on the website and not inside the app.
I've never built up an Android app, so I'm asking for understanding if this is a dumb formulation. I just want to help my co-worker and he seemed to struggle with the details.
Is there perhaps a smoother way to make the call to a web service if I substitute the patter of the URL to use query strings? Any other approach that makes it easier for an Android developer? I'm not familiar with the area but I want to make things easy for my team-mate.
There are quite a few different HTTP libraries available and it would really depend on your specific requirements which one you used (if any - you can roll your own HTTP requests using HttpURLConnection) Two of the more popular ones are:
Volley
http://developer.android.com/training/volley/index.html
Written by one of the guys on the Google Play team and part of the AOSP. Very flexible and easy to use however I would hesitate to recommend it as it relies on the now deprecated Apache Http classes in its public API.
Retrofit
http://square.github.io/retrofit/
From Square. Version 2 is currently in late stages of beta. It allows you to define your API as an interface. It has dependancies on their OkHttp library as well. Very fast and also has RxJava support baked in.
I am developing an Android application, in which I want to make a calls using internet using SIP in android. So I need to maintain my own SIP sever for my app users, how can I create my own SIP server?
I would not advise creating your our sip server as it would take a large number of man years of development and there are a lot of pitfalls.
There are some open source implementations that you could install and setup yourself. Like FreeSwitch or Asterisk. Both are large and complete to setup as there is a lot of domain knowledge required to understand how to set them up correctly.
There are also free server that you could try out as well like Sip2Sip.
Then there is the job of creating a sip client on Android. Again it's not that simple either. I would look at using a open source library here as well, like pjsip. This gives you the advantage of being able to look at examples of full sip clients already developed for Android like csipsimple. pjsip also has the advantage of being cross-platform, so you could reuse it in IOS for example.
Good luck.
The Server
As a communication server, choose for example sip:providerCE v2.6. The easiest way to get started with it is to download the VMware or Virtualbox image and fire it up on a suitable machine. If you get more serious, you want to install the system from scratch on a dedicated server with a public static IP. If you’re new to VoIP and SIP, do NOT try to install it on an Amazon EC2 instance, as they’re using destination NAT, which is a big pain for SIP and needs some experience with the SPCE to tweak it properly for that scenario.
Note that the SPCE is a 64bit system, so in order to run the VM images, you need to turn on 64bit CPU virtualization in your BIOS if VMware or Virtualbox warns you about it.
...There is very good tutorial HERE! on how to set things up.
...Don't forget there is a technical advise concerning SIP check the accepted ANS!
...Least but not last check THIS! VOIP Wiki, It covers everything related to VOIP.
SIP RFC is very easy protocol to implement. Just create a socket listener and implement RFC-3261. Start with with a basic codec GSM, then move up to A-LAW (G.711), as needed.
The tricky parts with SIP are (A) ensuring your call flows are correct (RFC-3665) and (B) media encoding/compresion. Use Asterisk (FreeSwitch) and WireShark to test your call flow. If you need DTMF support you'll need RFC-2833. If you need advanced codecs, consider using open-source library like FFMPEG.
I used uSIPserver on android. It works well and support video call. If you use client app which supports video then you can video call eachother on wifi.
It is so simple to use.
Good luck :-)
I am currently involved in a project where we performed some computer vision object recognition and classification using python. It is necessary to use photos taken from an Android phone (photos should be automatically sent from android to python). I actually don't know how should I connect both applications (android and python) together. I thought of using TCP Server, but I am new to socket programming and don't know how and where to start.
Any one can help?
Android gives you options to connect via HTTP.
http://developer.android.com/guide/topics/connectivity/index.html
So I would probably go with a REST type implementation
https://en.wikipedia.org/wiki/Representational_state_transfer
http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm
Here is a tutorial for Android and REST
http://www.majidkhosravi.com/android-rest/
But you are dealing with pictures. Here is a SO talking about that.
POSTing image from Android to WCF Rest Service
On the Python side you have multiple choices, but the main ones I would consider:
Twisted (or maybe Tornado) if you want Asynch.
http://twistedmatrix.com/trac/wiki/WebDevelopmentWithTwisted
http://zenmachine.wordpress.com/web-services-and-twisted/
Flask for Synch.
http://flask-restful.readthedocs.org/en/latest/quickstart.html
Maybe Nginx/Apache + Django
http://django-rest-framework.org/
SO post about Python and REST
Recommendations of Python REST (web services) framework?
If you want to implement this at the socket level, this book would be a great resource:
http://www.amazon.com/Foundations-Python-Network-Programming-Goerzen/dp/1590593715
Hope this helps provide you some directions to explore.
poof's answer is a good overview, but here are some notes on the various options:
Option 1: Have your Android get the picture and do a HTTP POST to a Python application running a framework such as Django. It should be 1 line of code on Android, and only a few lines of code on Python (around your existing code).
The upside is that the low-level "Glue" is written for you, and it scales easily. The downside is that HTTP has some overhead.
Option 2: Have your Android talk a custom TCP protocol to a custom TCP application.
This is more work, so you should avoid it unless you need it. It will be more efficient and have lower latency, especially if you're sending multiple pictures. The response can also be much smaller without HTTP headers.
In either option, you don't have to send a JPEG, you could send any custom format you want (there is a trade-off between compression on Android and size of file).
I thought of using TCP Server, but I am new to socket programming and don't know how and where to start.
Start where everyone else started - by reading a lot and playing a lot. You can find plenty of introductions to Socket programming in Python on the web. Go thru the tutorials, and start modifying them to see how they work. Read up on TCP/IP itself -- there are a lot of dark corners (Nagel, fragmentation, slow start) that can affect how you write the app when you get to a low level.
I am looking for general advice (technologies, best practice etc.) regarding the development of a VoIP application for Android. Similar questions have been posted, but I included specific questions.
I did quite some research and I noticed that there are several possible solutions (of course I know about the SIP stack in the SDK (also that it includes even voice transmission), but since it's not available on most devices, I don't intend to use it. Also, I read about Adobe Flex implementations but I would like to stick to something native).
What stuck to my mind is the following:
initiate the session using SIP (the server exists). Use SDP in the messages to discribe the session.
establish p2p connection (firewalls/routing may be a problem - STUN could be used - DNS may be involced than)
make actual transmission, I believe that the packets/procols involved are (payload) in -> RTP in -> UDP in -> IP.
This seems quite complicated at the moment so my first question is:
1)is this a standard approach? Is it best practice? I got some hints that, instead, MSRP could be used to transmit content, but I have read that it is only for IM, files etc.
2) Which SIP stack should I use for the best results/performance? I can use Java/Eclipse for development. I was thiking to choose JSIP (or tinysip, based on jsip) but am not sure.
3) Please give me a few hints about how to implement the data transmission in Java for Android (RTP)
As a last note, I am not excluding at all pjsip. I am thinking that it may be actually faster since it uses the NDK (I could switch to C++, np) . I also read that it already includes audio/video transmission.
I just don't know how easy it is to use and extend it and how good it really is. If you have used it, please let me know!
Thank you.
PS: Although not urgent or certain, portability may be an important factor for future.
I will need video transmission as well in the near future.
You should check out the IMSDROID project. It uses Doubango Framework which is written in C and is highly portable. What more, it is open sourced too so you can play around with their code and possibly contribute towards the community.
http://code.google.com/p/imsdroid/
cheers :)
Take a look at teamSpeak. They provide native sdk-s. But they aren't free.
It's not P2P, requires a server (at least as I know)
May worth a minute.
http://www.teamspeak.com/?page=teamspeak3sdk
Writing your own SIP stack takes a few months with only basic features.
I would recommend to use an existing sip stack. There are a few opensource discussed here.
I am not aware of any application on android that is capable of downloading torrents. So in-case I would like to port an Ubuntu application like transmission or another similar light weight application would it be that easy. How much of socket programming would I actually require to do in such a case.
Also if anyone is aware of a project of this nature which is ongoing, I would love to have a look at it. I specifically intend to do this for android 1.6 and 1.5, so I think that makes any new API's which might have been released for this purpose pretty redundant.
dTor is a fairly new but very nice torrent client for Android devices. Despite its poor reviews on the Market, I have found it to be much better than all of the competitors. The developers are very active and there has been updates to it every week for the past month which have been making it much more stable.
You can check it out here: http://www.androlib.com/android.application.com-dtor-jwttw.aspx
Some programs exist under Androïd, but they usually only activate a remote bittorrent client from your computer for a specific file.
However I've heard of two real bittorrent clients projects, but didn't have a look at them :
aBTC : http://www.androlib.com/android.application.org-ale-abtc-qmzp.aspx
Marvin : helloandroid.com/apps/marvin-bittorrent-client
Well, such things exist:
http://www.androlib.com/android.application.org-ale-abtc-qmzp.aspx
http://www.androidzoom.com/android_applications/tools/andtorrent-bittorrent-client_fywo.html
EDIT: however, they are not for free...
To download a torrent application, download utorrent from playstore and torrentsearch app. Torrent search is like a search engine for torrent and when you get the file you want after searching just click on the file and it will automatically download on your utorrent/bittorrent app. This is a substitute for searching on the web browser