Garmin Communicator Plugin API released

Looks like Garmin is starting to release it’s APIs to the public.

This is something that a lot of the posts on the developer forum have been looking for. I have been looking at the slightly hidden Garmin Connect Webservice API’s (http://connect.garmin.com/proxy/activity-service-1.2/) lately and there are lots of great things that can been done with them. Anyone that has a Garmin Forerunner 405 watch will know how great the great the Garmin connect website is. You can analyse your run, down to the nth degree. Great for any ‘Stats heads’ out there. Using the Garmin connect API’s you can now view your Garmin connect content via a JSON rest request to their API.

More details on the Garmin Connect plugin can be found here but here is an over view of the Architecture:

The Garmin Communicator API is a JavaScript framework that hides the details of working directly with the underlying browser plugin. It consists of three tiers, each more user-friendly than the one it builds on.
The easiest to use is the DeviceDisplay which can be added to a web site with just a few lines of configuration code. The next tier down is the DeviceControl which is for JavaScript programmers who need more control over the event model. Lastly the DevicePlugin is a low-level plugin wrapper for developers who need bare-metal access.

, , , , ,

No Comments

Example using JQuery and CSS for DIV Slideshow

Over the last few months I have been helping my dad with a new website for his self catering holiday home in Galway. It gave me an opportunity to create a wordpress theme using thematic theme framework as well as look at some features of JQuery.


The Issue

One issue that he had with his old site was the very long page used to display all of the rooms in the house. It listed each room, one above the other with a picture and a description.

I wanted a way to display each room description and picture in a slideshow so only one room is displayed at any one time. I saw an example of a JQuery slideshow here that change the image from a list on a button click. I wasn’t interested in animating the image sliding across but it showed me how to use JQuery to change the order of the elements on the page.

$('#slides li:first').before($('#slides li:last'));

This takes the first li child of an element with an id of ‘slides’ then places it before the last li element. The example uses CSS to hide all of the other elements of the list so that only one element is shown at a time. When the JQuery code above moves the first element to the end, the second element is show. This is the CSS that makes this all work:

#slides {
  overflow:hidden;
  position:relative;
  width:250px;
  height:250px;
.....

As the height and width of the of the surrounding element is fixed and overflow is hidden, you will never see the other elements in the list.

My Solution

So with this example in mind, I set about defining a div for a room that I would display. This contains 3 other divs with the following class: roomName, roomImg, roomDesc. I also added a clear div to the bottom of each room definition to make sure that the content did not overflow.

Kitchen
  • Rangemaster cooker with gas hob & electric oven
  • American-style fridge
  • Belfast sink
  • Granite worktops
  • Dishwasher
  • Kitchen table comfortably seats 12 diners
  • Radio/CD player
  • Dual aspect
  • Double doors leading onto upper terrace

The CSS is similar to the example that I was using. Again, the important part is to make sure the surrounding div has overflow set to hidden so that only the content of one room is shown at a time.

  .clear {clear:both}
  .roomList{
  	width:640px;
	height:355px;
	margin:0 auto;
	overflow:hidden;
	position:relative;
  }
  .room {
	min-height:350px;
  	width:570px;
  }
  .roomDesc {
	float: left;
	max-width:240px;
  }
  .roomImg img{
	max-width:300px;
	max-height:350px;
	vertical-align:text-top;
	float: right;
	position:relative;
	padding:5;
  }

I changed the JQuery from the example to rotate the order of the div elements that I created when a previous and next button is clicked. As I didn’t want to animate a slide effect like the example, I just faded out the element before changing it and then faded the new element back in.

jQuery('#prev').click(function() {
			jQuery('.rooms').fadeOut('slow', function() {
				//move the last item and put it as first item
				jQuery('.room:first').before(jQuery('.room:last'));
				jQuery('.rooms').fadeIn('slow');
				setButtonText();

			});

        //cancel the link behavior
        return false;
    });  

    //if user clicked on next button
    jQuery('#next').click(function() {
      		jQuery('.rooms').fadeOut('slow', function() {
				//move the last item and put it as first item
				jQuery('.room:last').after(jQuery('.room:first'));
				jQuery('.rooms').fadeIn('slow');
				setButtonText();

		});
        //cancel the link behavior
        return false;  

    });

The setButtonText function is used to set the title attribute of the previous and next button to the next and previous rooms in the list. the

function setButtonText()
{
	jQuery('#prev').attr('title',jQuery('.room:last .roomName').html());
	jQuery('#next').attr('title',jQuery('.room:nth-child(2) .roomName').html());
}

The Demo

You can see this example in action on the accommodation page of Riverside Paradise.

Thanks to Kevin Liew for putting me on the right track with this JQuery slideshow example.


, , , ,

3 Comments

The Android Thread Police are coming….

As part of the Gingerbread release of android, a new API, StrictMode will allow developers to set a policy on a thread.

StrictMode is most commonly used to catch accidental disk or network access on the application’s main thread, where UI operations are received and animations take place. Keeping disk and network operations off the main thread makes for much smoother, more responsive applications. By keeping your application’s main thread responsive, you also prevent ANR dialogs from being shown to users.

StrictMode will only come into play if you select it and allows you to detect the following situations:

  • detect disk writes
  • detect disk reads
  • detect network usage
  • on a violation: log
  • on a violation: crash
  • on a violation: dropbox
  • on a violation: show an annoying dialog

Enabling StrictMode

StrictMode can be enabled in your applications onCreate method

public void onCreate() {
     if (DEVELOPER_MODE) {
         StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
                 .detectDiskReads()
                 .detectDiskWrites()
                 .detectNetwork()
                 .penaltyLog()
                 .build());
     }
     super.onCreate();
 }

This blog post on the Android Developers blog by Brad Fitzpatrick will give you an overview of what you can expect. You can also check out the StrictMode API here for more details on what it allows.

, , , ,

No Comments

Major changes for Android Market client

Over the next two weeks Google will be rolling out a major update to the android market client. The changes will greatly improver the user experience as well as the browse-to-purchase experience. It will also be possible to develop richer games with the increase of the max size of .apk files to 50MB.

The Android Market engineering team has been hard at work on improving the Android Market experience for users and developers. Today, I’m pleased to announce a significant update to the Android Market client. Over the next two weeks, we’ll be rolling out a new Android Market client to all devices running Android 1.6 or higher.

This new Market client introduces important features that improve merchandising of applications, streamline the browse-to-purchase experience, and make it easier for developers to distribute their applications.






With a focus on improving discoverability and merchandising, we’ve introduced a new carousel on the home and category screens. Users can quickly flip through the carousel to view promoted applications and immediately go to the download page for the application they want. Developers have been very active in creating great Widgets and Live Wallpapers. To make it easier for users to find their favorites, we’re introducing two new categories for Widgets and Live Wallpapers. Applications that include Widgets and Wallpapers will be automatically added to those new categories. We’ll also be adding more categories for popular applications and games in the weeks ahead. In addition, the app details page now includes Related content, which makes it easier for users to quickly find apps of similar interest.

You can read more on this at Google’s Android Developer blog.

, ,

No Comments

Android 2.3 (Gingerbread) is the fastest Android yet and out now

Google have release Android 2.3 today and they are claiming that it is the fastest version yet. From a performance point of view, there is now Concurrent garbage collector, Faster event distribution and Updated video drivers. It looks like they are trying to push into the gamers market with many of these new features.

Here is an overview of the main features of Android 2.3 from the Google release:

Enhancements for game development: To improve overall responsiveness, we’ve added a new concurrent garbage collector and optimized the platform’s overall event handling. We’ve also given developers native access to more parts of the system by exposing a broad set of native APIs. From native code, applications can now access input and sensor events, EGL/OpenGL ES, OpenSL ES, and assets, as well a new framework for managing lifecycle and windows. For precise motion processing, developers can use several new sensor types, including gyroscope.

Rich multimedia: To provide a great multimedia environment for games and other applications, we’ve added support for the new video formats VP8 and WebM, as well as support for AAC and AMR-wideband encoding. The platform also provides new audio effects such as reverb, equalization, headphone virtualization, and bass boost.

New forms of communication: The platform now includes support for front-facing camera, SIP/VOIP, and Near Field Communications (NFC), to let developers include new capabilities in their applications.


See what applications are running

One personal gripe of mine has been the low battery time on Android. I recently upgraded my Xperia X10 to 2.1 and found the battery to last a bit longer but 2.3 has addressed the problem as well. As you can see from this screenshot, there is now a “Running” tab that allows you to see what applications are running. From here you can choose to close the app or report feedback to its developer.

Near Field Communications (NFC)

One of the new features that I am really excited about is Near Field Communications that allows the device to read NDEF tags. This is going to allow for the development of a whole host of applications. The obvious one being, “Swipe to pay” applications that will allow you to pay for goods using an app on your android device.

An NFC Reader application lets the user read and interact with near-field communication (NFC) tags. For example, the user can “touch” or “swipe” an NFC tag that might be embedded in a poster, sticker, or advertisement, then act on the data read from the tag. A typical use would be to read a tag at a restaurant, store, or event and then rate or register by jumping to a web site whose URL is included in the tag data. NFC communication relies on wireless technology in the device hardware, so support for the platform’s NFC features on specific devices is determined by their manufacturers.

Checkout the video below for an overview of all of the new features:

For more information about Android 2.3 visit the Platform Highlights page.

, , , , ,

No Comments