Thursday, May 21, 2009


From Android to AppEngine

So I've finished the first (crude) iteration of my Android app, and am now moving on to creating a web application that will act as middleware.

Why a web app? Well. My Android app basically consists of grabbing the phone's current location, adding a picture and notes if the user so desires, and uploading this data to a web site. (I'm actually thinking of hiving off this basic functionality as a "Scout API" down the line, and releasing the code for future Android novices; I'm guessing that "hey, let's have people register / comment on the locations of $things1 when they come across them!" apps out there.

But a phone has very limited resources, from CPU to storage, and an annoying UI; so rather than make the user do everything on the phone, far better just to grab the on-the-spot data and do whatever further processing is required on a web site far, far away.

So I've started playing with Google AppEngine. Thus far it looks very easy, very powerful, and integrates seamlessly with Google Accounts, so you don't have to roll your own user infrastructure (and so you get locked into theirs....) It's also currently only available in Python, but what the hell, I was getting bored of Java anyway, right? More on AppEngine in the next post.

Other things I learned about Android:

Don't tug on SurfaceView's cape

The camera API is surprisingly simple, and Android comes with a SurfaceView which, among other things, lets you easily display a real-time camera preview (if you subclass it.) My intent was to have the "take picture" and "see preview" user actions be part of the same Activity - ie, when the user selects "take picture", stop showing the preview, and instead draw that snapshot on the SurfaceView.

This did not work well. SurfaceView is a very weird artifact and a difficult one to play with. After about two hours of beating my head against the problem I wisely decided to create a "ShowPicture" Activity with an ImageView, which was much simpler, and worked much better. Moral: don't overload any given Activity. Keep 'em simple, stupid.

Also, because I subclassed SurfaceView into CameraView (as per the Camera example in the API Demos that come with the SDK) I had to have a two-level callback structure: in my Camera Activity, there was a TakePicture button, which called "takePicture()" in my CameraView, which instructed its Camera to snap a shot. Then there were three callbacks in CameraView (one to indicate success, one for the RAW, one for the JPEG) and in turn I had to callback Camera. This works fine, but is a little more convoluted than I'd like.

Be careful about where you are in the stack

Creating a new ShowPicture activity did create a new problem, in that the user navigation might be "edit note -> take picture -> see preview" and might be "edit note -> see existing picture -> take new picture". In the first case, after you take the picture, you want to open a new SeePicture Activity; in the second, you want to return to the existing one. The solution was to pass a flag in the Intent that goes to the Camera activity, indicating whether you're taking a new picture or replacing an existing one.

Always save when leaving a window

In theory, Android could kill your app at any time, to conserve resources. It will probably notify you before it does so (see the Activity Life Cycle.) So it's best to save all user-modified information in "onPause()", just on case. This incentivizes you to keep your database structures very simple.

This does create the cancellation problem as per my last post, but I think that's the lesser of two evils.

GPS is busted in the emulator

The emulator's mock location providers basically don't work. Fortunately, this basically doesn't matter, as you can roll your own if you really care.

1For the record, I hate Perl with an abiding passion, but the $ prefix remains the best way to signify "this is a variable" in prose.

Labels: , , , ,

google app engine now supports java, and therefore (more excitingly) a range of jvm languages. looking forward to playing with it myself, if i ever stop spending 15 hours a day in the offce
Hi Very Nice Blog I Have Read Your Post It Is Very Informative And Useful Thanks For Posting And Sharing With Us.
Carpet Cleaning Sunshine Coast
Carpet Cleaners Sunshine Coast

Great Article! Keep on sharing the update with us.
Carpet Cleaning Brisbane | Carpet Cleaners Brisbane

Thanks for sharing the info with us. Keep on updating us.
Movers Melbourne | Removalists Melbourne

Thanks for posting this.I got valuable information from your blog.
Carpet Cleaning Adelaide | Carpet Cleaners Adelaide
Do you require complete packing and furniture removal services from the specialist Removalists Melbourne? Then you should contact Quick Pick Movers Company and get our reliable and punctual home removal services. We have professional and well-trained Home Removalists Melbourne who have expertise in furniture removal services as they have wide experience in this field. Our aim is to provide stress-free and hassle-free home removal services at an affordable price rate. We handle every task from packing to unpacking so that you can be relaxed as well as tension-free in removal services.

Removalists Melbourne

Removalists Melbourne eastern suburbs

Removalists Melbourne south eastern suburbs

Piano removals Melbourne

Pool table removals Melbourne




Highlight your business brand on a very vast platform like Google with the help of honest and professional Advertising Agency Melbourne like Leap Agency. We can be your success-booster in the digital world with our experience and knowledge. Our Marketing Agency Melbourne adopts result-focused approach so that customer gets great success in their business via the digital world. Our team has creative ideas and the latest technology, so after combining them, they provide you with the best possible outcome in our services.

If you are searching for Tattoo Artist Melbourne who has deep knowledge as well as aware of the latest trend then you should approach us at City Of Ink and meet our artist team. In our shop, you can find all trendy and sophisticated designs which have style and attraction. Our entire design collection is created by our Tattooist Melbourne so come to our shop ad get a different look with a fashionable tattoo. From our tattooist, you get a fresh approach to tattoo creation.
Google App Engine backend module templates
Google App Engine enables you to run your backend applications on Google's infrastructure, without ever requiring you to maintain any servers.

To simplify the process of adding an App Engine backend to your app, Android Studio now provides three App Engine backend module templates which you can add to your app. You can find them under "New → Module" menu:

App Engine Java Servlet Module provides a simple App Engine Java backend servlet with minimal boilerplate code,
App Engine Java Endpoints Module template leverages Google Cloud Endpoints for your backend, and includes automated object marshalling/unmarshalling, generation of strongly-typed Java client libraries and so on,
App Engine Backend with Google Cloud Messaging includes both Google Cloud Endpoints and Google Cloud Messaging integration, which enables additional features like push notifications.

Looking for Plus Size Dresses which not only have trendy style but also well in the material? Then you should visit My Size online store where you can find your need dresses with an attractive discount. Whether you need Plus size Dresses for Women or plus size clothing your entire searching will end in our store. We have a vast collection of Plus Size Dresses Online service which is appropriate for every function as well as traveling.
Thanks for sharing informative post. Choosing best packers and movers Melbourne will make your house or office removal process lot easier. Piano movers Melbourne.
Gone are the days when you had to visit all the nearby plumbing agencies to choose one of the best plumbers in the town. NLK Plumbing offers you to get the best Plumber South Yarra at your doorstep in one phone call. We have an expert team that will handle your plumbing issues such as Plumber Sunshine in such a way like they were never there.
Thanks for sharing information. Choosing computer accessories from leading IT store offer great discount and value for your money Computer Store Australia | All in One Pc Australia
Thanks for a great article.We provide complete End of Lease cleaning /General cleaning Service that includes Dusting & Moping in Kitchen area, Bathroom area, floor,windows etc. at best prices. Same day service available.Call Now to book an appointment at +61 0414 534 770.

Is your D-Day near? Hire the leading hairdresser in Sydney from Sloans.
Thanks for sharing the updated news android to app engine!I like to recommend website development company in chennai | seo company in Chennai
After reading your article I was amazed. I know that you explain it very well. And I hope that other readers will also experience how I feel after reading your article.
Ethical Hacking Course in Bangalore
Certified Ethical Hacker Course
Wow! Such an amazing and helpful post this is. I really really love it. I hope that you continue to do your work like this in the future also.
Ethical Hacking Training in Bangalore
Ethical Hacking Training
Thumbs up guys your doing a really good job. It is the intent to provide valuable information and best practices, including an understanding of the regulatory process.
Cyber Security Course in Bangalore
Very nice blog and articles. I am really very happy to visit your blog. Now I am found which I actually want. I check your blog everyday and try to learn something from your blog. Thank you and waiting for your new post.
Cyber Security Training in Bangalore
I will really appreciate the writer's choice for choosing this excellent article appropriate to my matter. Here is deep description about the article matter which helped me more.
Best Institute for Cyber Security in Bangalore
I am impressed by the information that you have on this blog. Thanks for Sharing
Ethical Hacking in Bangalore
Certified Ethical Hacker Course
I am impressed by the information that you have on this blog. Thanks for Sharing
Ethical Hacking in Bangalore
Certified Ethical Hacker Course
Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
Data Science Training Institute in Bangalore
Great post i must say and thanks for the information. Education is definitely a sticky subject. However, is still among the leading topics of our time. I appreciate your post and look forward to more.
Best Data Science Courses in Bangalore

This comment has been removed by the author.
Truly mind blowing blog went amazed with the subject they have developed the content. These kind of posts really helpful to gain the knowledge of unknown things which surely triggers to motivate and learn the new innovative contents. Hope you deliver the similar successive contents forthcoming as well.

360DigiTMG Machine Learning Course
Wonderful blog found to be very impressive to come across such an awesome blog. I should really appreciate the blogger for the efforts they have put in to develop such an amazing content for all the curious readers who are very keen of being updated across every corner. Ultimately, this is an awesome experience for the readers. Anyways, thanks a lot and keep sharing the content in future too.

360DigiTMG Tableau Course
Incredible post I should say and a debt of gratitude is in order for the data. Schooling is certainly a tacky subject. Be that as it may, is still among the main subjects within recent memory. I appreciate your post and anticipate more. You have made some valid statements there. I looked on the web to study the issue and discovered a great many people will oblige your perspectives on this site...
paper airplane that flies far and straight | windfin | stable paper airplane | nakamura paper airplane | paper airplane templates for distance | paper airplane designs

I am more curious to take an interest in some of them. I hope you will provide more information on these topics in your next articles.
Data Science Course in Pune

It is really a great work and the way in which u r sharing the knowledge is excellent

Tally Course in Tambaram
Tally Course in Anna Nagar
Tally Course in Velachery
Tally Course in T Nagar
Tally Course in Porur
Tally Course in OMR
Tally course in Chennai

Wonderful Blog.... Thanks for sharing with us...
SQL Training in Velachery
Software Testing Training in Velachery
German Training Institute
Python Training Institute
Excellent Blog. Thank you so much for sharing.
Selenium Classes
QTP Classes
IOS Classes

Thanks for sharing great info … Hiring a limousine are excellent option to make your special occasion more delightful. Limo Hire MelbourneLimo Hire Melbourne Prices .
Hi I am very happy to look this valuable informative this helps me a lot car detailing Melbourne

Post a Comment

Subscribe to Post Comments [Atom]

<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]