Thursday, May 26, 2011

Connecting usb stuff to the Xoom and debug through wifi!

Today I played a lot with my Motorola Xoom trying to connect different devices.

We started connecting the tablet to the television using the hdmi output. We installed Snes9x EX and played some snes games. The great thing about Snes9x is that it allows to connect Wiimotes. The screen over the right shows a Killer Instinct fight!

Today at work they bought a Kinect to test stuff. Android 3.1 + usb host == kinect? I entered the freenode irc chat of the openkinect guys. They give me some excellent support but they doubted that it would work. I will try it out. If I found something useful I will do a blogpost about it.

USB keyboard/mouse
The usb keyboard worked fine but the mouse didn't. The mouse turns on, but the pointer doesn't appear in the screen.

Other Android devices
One of the samples of android-12 is called AdbTest. You can connect an android device and it will read the logs. I connect my nexus one and it worked fine.

Cool. Good results so far but I felt disappointed with the mouse, so I decided to try to read what the usb say for that device. When I was going to connect the mouse I discovered that I was missing an extra slot for debugging. I first based my code in the AdbTest and place my logs in the TextView.

After failing trying to get the device name I started reading the documentation, and I found there were Debugging considerations when using the USB Host and Accessory. There are five easy steps you need to do to debug without a usb cable.
  1. Connect the Android-powered device via USB to your computer.
  2. From your SDK platform-tools/ directory, enter adb tcpip 5555 at the command prompt.
  3. Enter adb connect device_ip:5555 You should now be connected to the Android-powered device and can issue the usual adb commands like adb logcat.
  4. To set your device to listen on USB, enter adb usb.
It does work!

I needed to post this before continue coding :)

Friday, May 20, 2011

App Review: ESPN 107,9. A real Honeycomb app?

On Thursday I went to the Motorola's MOTODEV. You can find a review of the event here. Thanks @fogo!

One of the sessions was called: "Moving Your Smartphone App to the Tablet". There they showed an app done in Argentina which was ported to tablets. My first thought was: "Cool, someone already ported something here in Argentina". Today I installed it and I found very interesting stuff in this app so I decided to create a review.

Installation and market place
I search for the app in the market and I found this:

This is what happens when you use two different binaries for the same app. Some of the issues are:
  • Different comments for the same app.
  • Different ratings for the same app.
  • Doing an update means uploading two different apps.
Is there a real difference between those binaries? We will see.

Patterns and features explained
In this section I will explain some of the patterns that the app uses. Also some features/issues and a way to solve them.

Splash Screen
This is something used a lot in iPhone's app. While an app loads in iPhone the os shows the image /Default.png or /Default@2x.png. It does make sense to use a splash screen if you need to load something before loading the application itself. One of the best examples is Roboguice's RoboSplashActivity:

An activity that can be used to display a splash page while initializing the guice injector in the background.
To use this kind of patterns the attribute android:noHistory is your friend. In the case of the app it looks like they didn't use it since there is a nasty bug that ends in a FC. If you enter the app and click "ProgramaciĆ³n" you can actually move back three steps when only two should be possible.

If you check their manifest you will notice that they are doing something like:

<activity android:label="@string/app_name" android:name=".ESPN_107_9" android:screenOrientation="portrait">


<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />



<activity android:name=".EspnHome" android:screenOrientation="portrait" />

<activity android:name=".EspnProgramacion" android:screenOrientation="portrait" />

<activity android:name=".EventoActivity" android:screenOrientation="portrait" />

<activity android:name=".Prueba" android:screenOrientation="portrait" />

<activity android:name="iphoideas.ESPN_107_9_TABLET.Example" android:screenOrientation="portrait" />

Some issues about this manifest:
  • It doesn't follow the java package name convention.
  • There is an android:screenOrientation="portrait" in every Activity when it can be placed just in the Application tag.
There is also an interesting use of android:name. In the manifest you can place a dot and that will be replaced by the package info placed in the manifest tag. As you can see, they have used both ways. The complete package name and the dot version.

Forced Portrait
This is what pissed me off as a user. No landscape view in the tablet version? Seriously?
The app has basically two Activities. The main one with a play button and some social features.

Social features
You can just send an email or paste something in your facebook's wall. Android has a lovely share intent to handle this stuff. You can get more information here.

System notification when playing
I started playing the radio and no system notification was shown. Not the same use case as the default music player?

No fragments? Honeycomb application without fragments? I don't like to have a big play button in the main window and need to move to something else just to see the radio guide.

Creating a landscape layout having the radio controls in the same activity as the guide would have been great.

Stacked activities
In this app from the Home you can go to the radio guide and from the radio guide you can go to the home screen. So, you basically can do Home => Radio Guide => Home => Radio Guide. What happens if you press the back button? In this particular app all the activities get stacked but for this kind of situations android provides a solution. Using FLAG_ACTIVITY_CLEAR_TOP

For example, consider a task consisting of the activities: A, B, C, D. If D calls startActivity() with an Intent that resolves to the component of activity B, then C and D will be finished and B receive the given Intent, resulting in the stack now being: A, B.

Enable Hardware acceleration
Unfortunately this app doesn't use it. To do it you just need to add the android:hardwareAccelerated="true" in the application element.

Using the Holographic theme
This app doesn't use the holographic theme. Everything in this app is custom so you might thing that it's not necessary but when dialog show up they aren't custom and they don't use honeycomb styles.

If you are targeting smartphone and tablet you can use:
<uses-sdk minsdkversion="4" targetsdkversion="11"></uses-sdk>

Different resources for different screen sizes and densities
This app has every resource inside the res/drawable folder. Using the res folder correctly would be enough for this app to live in the same binary. There is a nice explanation about this here.

The conclusion is dead simple. This is not a honeycomb app. It works in honeycomb because it has: <uses-sdk android:minSdkVersion="7" />. It isn't targeted for Honeycomb and it doesn't use android 3.0 features.

Does anyone know if someone in Argentina already did a good honeycomb app?

Tuesday, May 17, 2011

Google IO 2011: Day two

Second day
If you didn't read the view of the day day, you should read that one first.


After eating something we met with Jason Van Anden. Jason worked with me while I worked in Teracode but unfortunately I never met him in person. He has an interesting project called BubbleBeats.

He told us about his plans and his future projects. It feels good to know that Android developers are getting tons of work and they are progressing!


While the first keynote was all about android, the second day's keynote was all about chrome os and chrome browser.

Good news about ChromeOS. I think that everything sum ups to this sentence: "No need to bother fixing PC and having more time for yourself". I am particularly happy for that. I am tired of fixing PC with an OS I don't use anymore. As the times passes, it gets harder and harder to find the Control Panel :(

Google decided to give out chromebooks as a present but they are sending them on June 15th. I don't know how that will work for international attendees. I guess I will need to ask Al Sutton (@alsutton) :)

Building Agressively Compatible Android Games

This talk was given by Chris Pruett(@c_pruett). He was a Game Developer Advocate for Android at Google and now he has his own company. He once again talked about his experience with Replica Island and give out a big list of things to do and not to do.

I wish I could talk to him but he was surrounded by other people.


After Chris' talk we hang around some stands which were in the third floor. There were a lot of games to try out and also some robots going around. After some of them we decided to head for Lunch. 20 mins to eat before moving to the next session. I need to say that the food was excellent. We even had a Haagen Dazs' ice-cream as dessert!

Building Web Apps for Google TV

Chris Wilson (@cwilso), GTV developer advocate gave an excellent explanation about the TV platform in general. He mentioned that we should get everything away from the boarders since the Over-scan also applies to nowadays televisions.

He also mentioned a lot of recommendations for UI design. Some of the ones that stayed in my head were:
  • Remember the user is in couch-mode. Few interaction.
  • Avoid having a lot of clicks to reach content.
  • Design your app and see it from 10 feet (3 meters) away.
  • Instead of browsing downwards, the user browses rightwards.
  • Avoid scrolling. The user is not used to scroll TV content.
  • Make sure you make the user aware of where he is standing and what options are available.

Building Android Apps for Google TV

Similar to last session, these guys gave an intro to Google TV.

They explained that the API will provide different functionalities/issues. There are two which are pretty interesting or out of the ordinary.

1) You will not be able to know what the user is watching.

Wow! Really?

Actually you can learn which channel he/she is watching but no more than than. If your app/idea depends on that you will need to ask the user which tv provider he/she is using and parse it's tv guide. While it's a big issue right now, I guess some kind of open source project will appear to solve this.

2) Android fw will start to take care of where to place your ui widgets. eg: If you place an ActionBar in your app in a Tablet device it will show in the top right corner horizontally while for GTV it will show in the left vertically. I guess this is what android ice-cream sandwich will be about. Developer placing a ui widget and android deciding how to show it correctly. Third party UI libs will need to take care of that kind of customization if they are willing to stay alive.

I actually asked Roman Nurik what he thought of different third party UI libraries. My question actually was: "Should we continue using libs like GreenDroid or we should wait for this kind of magic customizations by Android?". He replied that for now we are good to use that kind of libs. They are an excellent way of applying android ui patterns.

GTV Office Hours
After the Android GTV talk, we went to the office hours. I wanted to buy a google tv to take back home but I wanted to be sure that I was going to get the 3.1 update with the adb and stuff. We fortunately found Chris Wilson who friendly replied to all our questions. I will try to reproduce:

We: Logitech or Sony?
Chris: It depends. The sony has a bluray but the Logitech is cheaper. If it's just for development I will take the Logitech one.
We: Which one do you use at work?
Chris: Both.
We: Who's in charge of the updates?
Chris: The updates are sent by Logitech and Sony themselves.
We: If we get a gtv and start using in our country, we will get it?
Chris: Yep, you will get it while the device is connected to internet.
We: Is it possible to root the device?
Chris: Official answer: no. On the other hand, there are people who did it. It involves welding.

GTV Conclusion
In general, GTV it's a US-only device for now. I got one for several reasons.

  1. Being able test gtv apps for clients from US.
  2. We want to explore the world of widgets for GTV.
  3. Porting cocos2d-x to GTV. I still need to make it work with Honeycomb but I will definitely want cocos2d-x to run in GTV :)

Bringing C and C++ Games to Android

Since we had some time we decided to go to this session to meet up with @emmby. We reached there for the Q/A. When we entered a guy was leaving and the speaker said: "Try staying, there is a present for everyone in this room". Yep, I also got a xperia play. I guess I will need to discuss with the cocos2d-x's guys how they are willing to support this kind of device.

How to NFC
I didn't attend this session, but @mpan_ did. He said that they spoke about the api in general but for now android devices with NFC will not be able to emulate a NFC card.

After party
After the conference we went out for some drinks with ppl known by @emmby. Going out with ppl that knew SF was excellent. We went to different bars and we ate in an Indian restaurant. It was actually the most spicy meal I ever had, but I enjoyed it a lot. Thanks guys!


The Google IO was excellent. Good amount of sessions, every technology showed it's work in progress and I got an excessive amount of gifts.

Every android release is very ambitious and the next one is going to to support cellphones, tablets and tv. I think that GTV will be the next big thing. I yet don't imagine my dad using an android powered device but I do imagine him using gtv. From my point of view gtv will bring new type of users to the android community.

We also need to pay attention to tablet apps. There are very few apps in the market. The user experience of a tablet user is very frustrating. I hope to see more tablet compatible apps. I guess I should start doing that with my own apps.

There are a lot's of ideas and stuff to do in my head. I will now need to find the time to do them all.

Cheers, and happy coding :D

Wednesday, May 11, 2011

Google IO 2011: Day one

Google IO 2011: Day one

Ok, here's my little review of the #io2011. I will try to focus in the technical stuff only.

Amazing stuff. It really feels like Android is taking to the next level.

There were a bunch of announcements with tons of stats but for developers, the important stuff was:

  • Android Honeycomb 3.1 will be rolling out for the Motorola Xoom.
  • ADK
Android honeycomb 3.1 will be available not only for tablets, but for Google TV as well. This means that if you target 3.1 you will be targeting Tablets + TV. Here are the platform highlights.

There is this new resizable feature and it feels like a widget is a must for a tablet app. And what about using widgets in googleTV? It looks like Android's widgets will turn into something important. I never did one so I guess that's something I will need to research about it.

Honestly I was expecting something like the ADK toolkit. This new idea of android accessories open a new world of ideas. I feel that in a couple of months I will start plugging in my cell phone on every appliance at home. I am not very good with electronics but I know someone that will be interesting in doing something with it :)

Talks and office hours
With Matias we decided to avoid most of the presentations for two reasons:
  • They were very crowded
  • We preferred to talk to the Android developers and ppl in general.
We did enjoy a lot of talks so I will try to sum up what we talk about.

Romain Guy (@romainguy)
Some weeks ago, I had a very hard time making ListView work with choices modes. Fortunately I got a nice answer by Mark Murphy. Just to give you an idea, choice modes just work fine if the view returned by the adapter implements the Clickable interface. This means that you need to create a custom view.

I speak to Romain about this and I suggested to throw an exception when the ListView uses a choice mode but the view doesn't implement Clickable. He basically said that the ListView might have different views, eg sections, so it would make sense.

There is not much to do but to understand how ListView works and use it correctly. I suppose I will share some code of this working and how to use it since the ViewHolder pattern is used differently.

Virgil Dobjanschi (@vdobjanschi)
Virgil is the speaker of one of the best io2010 talks. Maximiliano Gomez Vidal (@mgv) gives a nice explanation of Virgil's talk in his blog post: The revenge of the SyncAdapter: Synchronizing data in Android.

The last month we started working in a new honeycomb app and we decided to follow Virgil's advises. I can't share the code but here are some highlights of our approach:

  • One ContentProvider per REST call.
  • One SyncAdapter per REST call.
We reached to some issues with this approach. We had something like:
  • REST call for getting SMS threads.
  • REST call for getting SMS from a certain thread.
I guess you can notice the issue here. SyncAdapters can not have dependencies, or be called in a certain orden so our approach breaks with this. We also didn't want to merge both REST calls in a single SyncAdapter since we didn't want to waste user's bandwidth downloading SMS which were not needed (Typical example of threads in the left and message showing up after clicking in a thread).

So, after explaining everything to Virgil he mentioned that in the past he was doing something similar to us. Different sync adapter per model but he said that after discussing with other android developers he was doing:

  • Only one sync adapter per app.
  • One Content provider per db.
My immediate question was: So you are having long classes with big switch statements? His answer was yes.

I also asked how he was handling manual updates for different models and he answered that he was using intents. I assume that there is a cute switch statement as well :)


The place where we had lunch was huge. We had the chance to share the table with Felipe "java." Lang (@flang). He is part of the GTUG from Santa Fe, Argentina. The @santafegtug.


We ended up going to this talk. The talk was low level stuff but the speakers left a lot of time for questions. One of the best questions was: "If I do an android accessory does it need to get certified? What are the legal terms with all this?" The answer was: "Good question, issue a bug!"

The lack of legal terms was actually one of my concerns during the Google IO.
Music service, cool. Can I upload my music? Is it legal?
Movie rentals, cool. I can cache my movie to watch offline. Is it legal?
Google TV, cool. Is getting banned from some tv providers. Is it legal?

It feels like the technology is there but we are lacking some legal terms and information of what's possible and what's not.

All the ppl in the room got a ADK kit.
In the ADK talk I met Michael Burton (@emmby). He's the author of Roboguice, author of the Groupon's app and a very nice guy.

Nothing very important in this talk but just an excellent panel.
Unfortunately the questions weren't very interesting.

Android office hours
We team up with @emmby and we stayed in the android office hours room. There we had a change to discuss ideas with different people.

Roman Nurik (@romannurik)
Roman was very friendly. I had an issue with how fragments handled touches so I asked him about it. He mentioned that fragments had nothing to do with the View hierarchy. I will have to recheck my code and try to answer my own question.

With @emmby we were both concerned about issues in the android issue list. We asked @romannurik if someone was actually reading them :). He said yes but that they were full of work.

Diana Hackbood
I had the chance of talking to Diana. I founded an issue with the LatinIME while working for SwiftKey. She told me if I knew how to fix it, I could provide a patch in gerrit.

Virgil Dobjanschi + Michael Burton
After speaking with Diana I found that michael was speaking with Virgil. I jump into that conversation since I knew it was going to have a lot of juice.

Michael was saying that he was using AsyncTask instead of going through all the syncAdapter + ContentProvider thing.

Virgil mentioned that doing the content provider and designing the db was the first thing he did but Michael said that you could only do that when the APIs didn't change which wasn't his case.

We three agreed that the documentation for SyncAdapters was lacking and even when you understand it correctly, it was a lot of work. I take advantage of the discussion and asked Virgil if he tested some kind of framework like DB4O for his approach. He said that we wasn't willing to replace Sqlite since he could add performance tweaks easily. I guess it's something we should test out with @mgv and blog about :)

Rallat (@rallat)

At the end of the day we met Rallat. Rallat is a GTLUG member from Spain. He is also in charge of, a spanish android site.

Unfortunately he told me that he was changing the dates of the Spain's Droidcon.

After party

The after party was incredible. Lot's of good food and drinks. Nice music and even a bugdroid dancing techno music.

Pretty Good for a first day!

Update: Review of the second day.

PS: Blogger needs an offline chrome app. I am in the plane right now and I am not able to save my writing :(

PS2: My flight is leaving!