Making android app work with a python web server - android

I have a small android application made in eclipse.
Now i need to build a web server with python so they could work together.
Should i make a new python projekt then in some way link it to my application?
Or
Should i use jython and rebuild the app in a jython project?
I have used Visual studio before, and eclipse is not my hometown, så i would really appreciate clear answers.

You don't seem to have a clue about how the android app and the web app are supposed to work together...
You can (theoretically) use just any language and techno you find appropriate for the web app since the communication between the android app and the web app will be http requests / responses.
Also, you can use whatever code editor you want to write Python code, as long as it (the code editor) supports Python.

You can use Kivy to write Python apps that work on Android (as well as just about any other system). Python, they say, has a built in module that you can easily make a web server with. I'm about to try it, I believe.
See
* kivy.org
* http://m.linuxjournal.com/content/tech-tip-really-simple-http-server-python

Related

How to create an APK of a HTML5 to run on Android

I know that those kind of questions have been asked before, but I couldn't find a topic to help me.
I have been give a HTML5 game and I was asked to verify if I can run it on an Android tablet.
I'm a little bit confused with what I have to do? Should I create an Android project and import the file or is there an easier way to create an apk?
Thanks for your help.
You could look at Apache Cordova. This is a powerful environment made to support app development in HTML5. As such you should be able to literally copy your game resources over, run a build and have a full fledge Android App. Fun fact, provided you have access to OS X, Cordova will produce an iOS compatible app too.
If your game consists of HTML, CSS and JavaScript, such that it can be run off a modern web browser with no special plugins installed, rest assured it can run in an Android tablet.
You could access it directly from the tablet's browser or you can make an app (packaged in an APK and installed from it) which does essentially the same, but with a great benefit: the web page and the app can communicate (via JavaScript), enabling a richer experience.
Example of such communication: you're making an app for a web forum, and the link for "compose new message" opens an Android activity for writing that POSTs the result to the server, instead of constraining you to write in a small web browser form.
For more information on the subject, check out Android API Guides for Web Apps.

combining html front-end and python "back-end" in mobile app

My application has an html-based front-end and uses python logic on the back-end. This application needs to run offline, not connected to the internet, so by "back-end" here I don't mean a server running remotely, but rather python logic running side-by-side in the same app as the browser/html engine. For Windows or Mac desktop apps, I build a Chromium Embedded Framework application, and then launch a sub-process which runs a CherryPy python application built using py2exe (or py2app). The client and the server then communicate using normal http.
I'd like to achieve the same thing on both iOS and Android. I've researched several alternatives, but nothing seems to do quite what I need.
Kivy is close, but as far as I can tell it doesn't offer a browser/html front-end, but rather provides its own layout engine on top of OpenGL. It has an extension mechanism, but that seems to be more about extending the python side, not the front-end side.
On the other hand, I could start with PhoneGap and then add a python library as an extension (possibly using Kivy's mobile library build of python). Or for that matter I could just write a regular C++ app that embeds a browser and uses a python library build.
On the third hand, I've played with using various python-to-javascript converters to get the back-end logic into something that can work with PhoneGap directly, but that approach gets pretty difficult given all of the python logic I have -- some of it just doesn't convert so easily.
Do you know of apps that are displaying html and running python logic in the same app?
You could do a very simple kivy app, that would start a service (inside which you would do your "server" side, with a small engine like flask or bottle, but i guess cherryPy should work too), and in the main.py of the "kivy" app, don't import kivy, just import webbrowser and start a browser window to localhost:your port. This will use the android browser.
edit: oh, services are android only for now, apparently ios 7 supports them too, but kivy-ios hasn't been updated to make use of them.

phonegap development environment

I'm trying to get setup to do mobile development using phonegap so i can deploy my application in android store and apple store. It's my understanding that I can simply wrap my application in phonegap so I can deploy for Android, iOs, BB, etc.
My application is an ASP.Net MVC app written with VisualStudio. All of the examples I've read through in my research tells you to use Eclipse for PhoneGap and Android, use XCode for PhoneGap and iOs. My app is ASP.Net MVC that produces Html 5. Is it possible to use PhoneGap with VisualStudio to produce Android and iOS deployable phonegap apps?
One alternative I've been thinking about is creating a simple Index.html page that uses jQuery to make a call to my ASP.Net MVC app and load the resulting HTML inside a div. Then I can simply reproduce this very lightweight Index page in Eclispe, XCOde, etc to run through Phonegap. This seems like a hack though. I've tried getting this to work but have not had any luck in the Android emulator in my windows environment.
Can someone please point me in the right direction for how to incorporate PhoneGap with my ASP.Net MVC app? Thanks.
ASP.NET lives on your server, so anytime you reference any ASP.NET script, you'll have to make the URL an absolute one with a hostname: http://www.example.com/my-script.aspx. Any non-dynamic files should be stored locally on the device so they will function when there is no network connection. You can then just host the dynamic files on your server and reference them whenever you need to. To keep data transfer size as small as possible, I generally pass JSON or something similar to the app. from my server-side script and then interpret the data into HTML in the JavaScript code for the app.
You should keep as many assets as you can local on the device so it doesn't require an internet connection to use the app. So don't link to a remote version of jQuery, save it as a part of the app. package you create so it's always available.
Eclipse/Xcode are nice because they help you create your app. and package it properly for submission to app. stores. They are also nice because of how easy it is to find help using Eclipse or Xcode to create apps. Xcode is actually required, Apple makes sure you have bought the latest hardware and the latest software just to be able to submit an app. to the store.

Writing and deploying Android app

So I want to make an app to scrape random inspirational quotes from a website, then show me them on my Android phone. What steps do I need to do this? Preferably I'd be able to do it in Clojure... if not that, then Ruby, if all else fails Java.
What do I need to do to write the app and importantly, to deploy it?
Hm, that's a very general questions with not a lot of info, but here are some random pointers for different parts of our question:
Enlinve: Scraping with Clojure
An Enlive tutorial
Screen Scraping with ScrAPI: A screencast on scraping in Ruby
Mechanize for scraping in Ruby (Nokogiri and Hpricot could also work)
Rhodes for Android development with Ruby
An Android application is developed in Java. You can also solely use C++ in the most recent version, but I think that's not what you're looking for. There are, however, a few hacks you can use to write less Java.
Are you familiar with Mirah? Mirah looks a lot like Ruby but it's statically typed. You can use Mirah to develop Android applications. Have a look.
You can also use Ruby, by taking advantage of the JVM (JRuby). Daniel Jackoway developed Ruboto in last years' Ruby Summer of Code. Ruboto allows you to develop Android applications in Ruby. Have a look.
Concerning site scrapping, one option is to use Nokogiri as Michael mentioned. It'll work in both Ruby and Java, but in the latter you'll have to hack a bit — not everything is currently working. There are a lot of HTML parsers for Java as well, namely HTMLparser or JerichoHTML.
Android applications are officially developed in Java/C++ but, as you can see, there are other options. Don't forget to take into consideration that by choosing these other options you won't be able to take advantage of the Android SDK.
The path of least resistance on Android would be Java. The app works basically like any other "screen scraper": pull the page, parse it, and display the information. How easily it is to parse will depend on how well structured the content is on the original site. If it happens to have an RSS feed you can probably use one of the many open-source Java RSS Parsers.
If you already have a server side program to acheive this, you can create a webview activity in android to show the same. So you can create your server side program in a language of your choice.
For me phase 1 would be to write a web app and access it using the Android web browser. You can use a JavaScript library such as jqTouch to make the web app look just like a native Android app, and you can access the geolocation api from the browser using HTML5.
I've built an iPhone app demo using this approach with compojure on the server and deployed to google app engine. It worked well.
Cheers,
Colin

Can we use Tomcat Server in android app

I am developing Android Web App using JSP with xml parsing. I developed it in Java using Tomcat Server but I couldn't develop in Android. I am new to the web app development. So can anyone kindly suggest me how to proceed further...
waiting for a response guys...Thank you
It is likely that you don't need tomcat on android. After all tomcat is (apart from everything else) a web server. This means that the phone your app is run within should be serving requests from other clients. I doubt you can make sure your phone IP is fixed, and even if that's the case, phones are not meant to be servers.
What I suspect you have done is - you've implemented some functionality in the context of JSP and servlets, but this functionality can easily be run without jsp/servlets. Remove the servlet-api.jar from your classpath and make your functionality work without these. Then you can easily use it in an android app.
While it should be possible from just the hardware standpoint, it should be nearly impossible to get tomcat running in the dalvik pseudo-java envrionment that android provides. the dalvik vm that Android uses is not a Standard Java VM, hence tomcat can't run on it.
I would suggest to look into the Maemo world, specifically the n800 and n810, which are a bit more hackish but also a lot more closer to linux than android. I've successfully run OSGI based apps on those machines. And they are still mobile devices you can use.
Check this site for some examples: http://wiki.maemo.org/OpenJDK_6.0_0_%28Cambridge_Software_Labs%29_on_N900
Look at i-Jetty. It's a web server that runs on the Android platform.
Why crazy? It is possible to make an ip pseudo-staic and then use a phone or tablet as a server instead of running a big power consumpting desktop 24/7. Of course for very simple purpos3 and probably as an experimental stuff. But not bad idea. I have written few years ago a tool for intarnal lan communication in the company which comprises synced and asanced messaging sastem, files and folders exchange functions, firewall solved access and everything in one jar cca 390 kb without any dependencies...there is also built in a http servlet and it runs on dalvik without problems - I have tested it. So the way is there, Even if the intention is not 100% clear.
You want to run Tomcat inside Android using dalvik? That is crazy. If it is a Web App host it somewhere and use the browser.

Categories

Resources