Android Apps, GPS, and Google Play

Here’s a little tip if your Android app makes use of location based services but doesn’t require them. We were getting a few emails from users that the app wasn’t available in Google Play on their devices. Most of the devices were more obscure tablets and low-end phones that didn’t have GPS functionality.

It seemed to be related to the fact that our app uses GPS and/or network location in order to geotag posts. This is not a required feature so we had this line in our AndroidManifest.xml file:

        android:required="false" />

Turns out this was not good enough, as you need to be a bit more detailed about what your app is using but is not required:

        android:required="false" />
        android:required="false" />
        android:required="false" />

After we published that change to the manifest file, the app was available to 160 more devices. Woo!

Taking the Metro: for Windows 8

Today Microsoft unveiled the Windows 8 Consumer Preview at Mobile World Congress and demoed our new app during their presentation. I was able to be a part of a great team at Automattic (including MT and Stephane) that built the app.

The app creates a beautiful reading experience for browsing the Freshly Pressed posts and the ability to like and reblog the post you are reading. It also includes some great social features that makes it easy to share content from other Windows 8 apps to your blog effortlessly.

The app is free and is already available in the Windows Store, so download the Consumer Preview and check it out! The app is also open source so have a look at if you’re curious about developing for Windows 8.

How to Get an NSDate for a Specific Day of Week and Time from an Existing NSDate

Worst Post Title ever! This one took me a bit to figure out so I thought I’d post it in case anyone else out there had troubles. I wanted to get an NSDate for a specific day of the week and time from an existing NSDate object in order to create a countdown timer.

This example will get you the NSDate for the following Monday at 8am:

NSDate *today = [NSDate date];
NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
[gregorian setLocale:[NSLocale currentLocale]];

NSDateComponents *nowComponents = [gregorian components:NSYearCalendarUnit | NSWeekCalendarUnit | NSHourCalendarUnit | NSMinuteCalendarUnit | NSSecondCalendarUnit fromDate:today];

[nowComponents setWeekday:2]; //Monday
[nowComponents setWeek: [nowComponents week] + 1]; //Next week
[nowComponents setHour:8]; //8a.m.
[nowComponents setMinute:0];
[nowComponents setSecond:0];

NSDate *beginningOfWeek = [gregorian dateFromComponents:nowComponents];

Now that you have the new NSDate, you can calculate the difference between the two by using fromDate.