Wednesday, May 25, 2011

Answers to Unanswered Questions from the I/O Protips Q&A

There's never enough time for Q&A at the end of an I/O session - particularly when the session is immediately followed by lunch. In an effort to remedy this, here are the answers to most of the questions that were entered onto the Moderator page for my Android Protips talk.Eclipse is a wonderful development tool. However sometimes it is clunky. Generic error messages, mysteriously build problems solved by quitting & relaunching, etc. Do you ever get frustrated with Eclipse? Do you have any tips of working with Eclipse?I do! Almost as much as I was frustrated by Visual Studio in a previous life spent writing C# Winform GUIs. I don't have any specific tips beyond the things that work with mode IDEs. Frequently restart and make sure you're using the latest stable build along with the latest version of the ADT.Do you have any tips for working with SQLite databases through eclipse? At the minute I rely on external tools to view data that is in the database on the phone to debug problem. This means manually copying it off the device. Any tips?You can use the sqlite3 command line tool to examine SQLite databases on the phone. It's not built into Eclipse but might save you the extra work of pulling the database off the device first.Do the developers at Google use any hardware emulators to speed up development. If so, can you please recommend some. The soft emulator is too slow.Unfortunately not. Generally we'll be working towards the release of the new platform on a given piece of hardware, so the internal teams will use that rather than an emulator where appropriate / applicable.Will there be a faster Android device emulator anytime soon?Yes! Check out this session on Android Development Tools for a preview.Is there a suite of AVDs for Eclipse that emulate actual devices?Some manufacturers make AVDs available for actual devices (I believe Samsung provide an AVD for the 7" Galaxy Tab). Generally speaking, no - there's no central repository or suite of all actual device AVDs.Will there soon be a legitimate way to replace the Android lockscreen (with a lockscreen application)?Due to the security implications, I'm not aware of any plans to make the lock screen (or in-call screen) replaceable. You mentioned better not to loose your signing key. But how to update your app, when your certificate expired?For now, certificates used to sign apps launched in the Android Market need to expire after 22 October 2033. We'll have a solution for replacing these certificates in place well before 2033 :)What's the recommended way to implement a horizontally scrolling, virtualized list?No simple answer here as it depends on the kind of data you're displaying, how long your list is, and what the best user experience would be. There are some good articles online (including this answer on Stack Overflow) that explain how to create a virtual list in a ListView, but you can use a similar technique within a Gallery or even a HorizontalScrollView to achieve a horizontal virtualized scrolling list.Are Shared Preferences the bast way to store small piece of data?It depends on what kind of small data you're storing. Shared Preferences are the best way to store user preferences and Activity / Application state information. A view from one app needs to be updated by another app. Can't use the widget paradigm, is there any other way?This depends on a number of factors. Are both apps written by you, or is one a third party? How dramatic are the changes? New layouts or changed text in a TextView?

Generally speaking, the best approach is likely to be a Broadcast Intent. You can package the data that will be used to update the View in the "other" app by including them as extras. The "other" app simply registers a Broadcast Receiver that listens for the Intent, extracts the data, and updates its view accordingly.How would you test/optimize the apps that are not meant for the Android Market?The principle of using Analytics for tracking bugs and doing A/B testing works just as well internally as it would on apps that will launch in Market. The biggest difference is distribution. Given the ability to side-load apps onto most Android devices, I'd most likely setup an internal website that would host the APKs you want to distribute for the Beta test.How can we know if a certain service is already running?You can bind to a Service using bindService without starting the Service. The Service Connection you pass in to bindService will notify you using its onServiceConnected and onServiceDisconnected handlers when the Service starts and stops. You can use those callbacks to set a variable within your code to check if the Service is running at any given time.Is there any option to backup the default SharedPreferences via BackupManager? Do I have to use the packagename?The default SharedPreferences file getSharedPreferences uses the Activity's class name as the preferences name.Is there a way for accessories to "push" an embedded app or service package to the device so that specialized services for certain types of accessories will be able to automatically add functionality to the device when connected?As part of the process of starting the device in accessory mode, you send identifying string information to the device. This information allows the device to figure out an appropriate application for this accessory and also present the user with a URL if an appropriate application does not exist. It won't install the package for you, but it will prompt the user to download it.Just to make sure, now we can send requests to the devices in order to update the info, instead of having the refresh intervals?That's right, you can use Cloud to Device Messaging to ping a device when it needs to perform an update.When will we have a UI Builder that is par to what we get for iPhone?!Check out this session on Android Development Tools for a preview of some of the cool stuff the tools team have been working on.Can you describe your video and control hookup for your android tablet?I wrote a blog post that describes the video and control hookup I used to do my presentation using a pair of Motorola Xooms.