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 C开发者_如何转开发lojure... 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
精彩评论