Thursday, July 2, 2009

Bookmarks Live Folder



Want a "live folder" for bookmarks on your android home screen?
http://market.android.com/search?q=pname:com.googlecode.livebookmarks

Labels:

New icon for Foursquared


Chris made me an awesome icon for the app. In return he got an alpha release! How lucky is that! Now for the low low cost of a line of code or cool menu icons, you too can have some buggy android software!

Labels: ,

Wednesday, July 1, 2009

Android, Foursquare and Push Notifications

How to get push notifications on Android.

As we all are aware its possible to run apps in the background in Android. The way push notifications work for the google apps like gmail and gtalk are by way of TCP connections with long TTLs. This allows the phone to wake up intermittently as the gsm radio will do (on the measure of microseconds) to see if new data has arrived on the wire. This implementation though, requires its own backend and for each service doing it, we'd be draining the battery even further...

Other work on Android Push:

XMPP/Jabber is even worse. Not only is xmpp/jabber a very chatty protocol, but as it works with one long xml stream, the disconnected nature of a cell phone does not jive well with it... holding an open xmpp connection is probably a very bad idea.

So where does this leave us with push notifications on Android if anything push we do is going to eat the battery and cause the user to uninstall the app?

One option would be to send periodic position updates based on some limiter (the API only has a radius accuracy of no less than a mile. We wouldn't have to wake up all that frequently for the common case of people don't drive around during night time activities). Knowing this, most of the work can be done on the backend to calculate "interesting things," and for notifications, we can send the response over gtalk. Specifically gtalk because most Android phones already have that previously mentioned long-lived tcp session that we can piggy back on. The message could be something along the lines of:

<a href="foursquare://com.playfoursquare.api.NotificationsAuthority/notification/12345?click=user">Mike M.</a> is hanging out at <a href="foursquare://com.playfoursquare.api.NotificationsAuthority/notification/notification/12345?click=venue">Mike's Bar and Grill</a>.

Users clicking on the link would be directed to the android foursquare app, where we could display awesome information.

I'd have to try this out to see if it actually works and how an android app would register as a global URI handler but it should be do-able.

Labels: ,

Foursquared Help

I'm looking for help on foursquared. I can start fleshing out some starter bugs and features so that anyone interested can just jump right in and code.

I've been hating git since I started using it and may end up migrating the SCM to HG on Google Code... I just feel more comfortable with both tools... Still not sure. If I have any external contributors it will really force my hand as I don't want to have to deal with emailed diffs and patches.

I'm not asking for testers because at the pace I'm going, the problems and features I'm trying to implement take up my allocated time plus a bit more. Increasing the water hose of bug reports and feature requests would just drown me. On the other hand, I did put together some crash reporting infrastructure while I was on the airplane so that when I do release, I can get automated bug reports: http://joelapenna.com/blog/labels/dumpcatcher (the code is at http://dumpcatcher.googlecode.com)

Right now I'm working on some troubling network connectivity issues (after some period of usage, all HTTP requests start hanging). After I resolve these issues I will be readed for limited testing... I'm content to release non-feature-complete if only to get some people looking at the app who might be developers.

I'm thinking that feature-wise the release will include the five screens I've sent before: http://joelapenna.com/foursquared/

Labels: ,

Tuesday, June 30, 2009

Fighting LiveFolders

Cupcake introduced "Live Folders" to the android world and since then I've wondered why the phone does not come with a LiveFolder implementation for bookmarks by default. In an effort to try and get code into core-android I set out to write it, but I've been struggling with all sorts of issues.

  1. ContentProvider.query returns a CursorWrapper, not a real cursor, which means if an existing content provider does not provide a live folders implementation and you want to write your own little content provider to proxy the requests with correctly formatted responses you'll have to implement your own cursor to delegate to the cursor wrapper. I resolved this by creating a MatrixCursor in my content provider into which I copy the columns from the BrowserProvider.
        public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
                String sortOrder) {
            Cursor c = getContext().getContentResolver().query(Browser.BOOKMARKS_URI,
                    Browser.HISTORY_PROJECTION, "bookmark = 1", null, null);
    
            String[] liveFolderColumnNames = {
                    LiveFolders._ID, LiveFolders.NAME, LiveFolders.ICON_PACKAGE,
                    LiveFolders.ICON_RESOURCE,
            };
            MatrixCursor mc = new MatrixCursor(liveFolderColumnNames, c.getCount());
    
            int columnCount = c.getColumnNames().length;
            while (c.moveToNext()) {
                Object[] row = {
                        c.getString(Browser.HISTORY_PROJECTION_ID_INDEX),
                        c.getString(Browser.HISTORY_PROJECTION_TITLE_INDEX),
                        getContext().getPackageName(), R.drawable.ic_launcher_shortcut_browser_bookmark
                };
                mc.addRow(row);
            }
            return mc;
        }
    
  2. I can't figure out how in hell I'm supposed to use ICON_BITMAP to set an icon for each item in the LiveFolder -- Looking at the source code it looks like its expecting a byte[], which I am in fact providing, but then the provider is having difficult constructing a bitmap out of that data and NPE's trying to (and I don't know why it is doing so) thumbnail the icon!

Labels:

Monday, June 29, 2009

Dumpcatcher: Uncaught Exceptions and Client IDs

Alright, about halfway through my flight and I now have an Uncaught exception handler that will post messages to dumpcatcher.

It doesn't work with android at the momement... There is a thread I know I have to read on android-developers. I think I starred it because I knew I'd find it uuseful.

The first user of this class was going to be Foursquared, but it turns out the code I wrote doesn't work.

I quickly added the ability to create a client id attached to each crash in order to allow me track each individual client and in the process refactored a bit of the code here and there. I'll have to remeber to update the design doc as I have made some changes to the design after noticing flaws in my original work.

Labels: , ,

Sunday, June 28, 2009

Dumpcatcher: Java Client

I'm on my way back from Cambodia... More on that later...

After spending about two-three hours working on hmac signing with Java I now have a working Dumpcatcher client for Java, this is similar to the python client

clients/python/logging/handler.py:Dumpcatcher
in that its usage is:
Dumpcatcher dc = new Dumpcatcher(PRODUCT_KEY, SECRET, "http://localhost:8080/add", 2);
HttpResponse response = dc.sendCrash(
    new NameValuePair("short", "Some short dump"),
    new NameValuePair("long", "some long dump")
)
    assertNotNull(response);
    assertEquals(200, response.getStatusLine().getStatusCode());

Have a look: http://code.google.com/p/dumpcatcher/source/browse/clients/java/src/com/googlecode/dumpcatcher/logging/Dumpcatcher.java?r=20090629r0

Now onto making a logging client for this guy.

Labels: ,

The views and opinions expressed in the blog are of Joe LaPenna. Google has nothing to do with these pages.
For information about Google please visit: Google Press Center