Java Archives - Intertech Blog

Android Adapters (and AdapterViews)

Android’s Adapter is describe in the API documentation, as “a bridge between an AdapterView and the underlying data for that view” (see here).  An AdapterView is a group of widgets (aka view) components in Android that include the ListView, Spinner, and GridView.  In general, these are the widgets that provide the selecting capability in the user interface (read about AdapterView widgets here).  What is not mentioned in the documentation is that the AdapterView also provides the layout of the underlying data… Read More

Android Non-UI to UI Thread Communications (Part 5 of 5)

This is the last post in my series regarding Android thread communications.  Parts 1 through 4 are linked in below. Part 1 Part 2 Part 3 Part 4 In this series, I have so far outlined four different approaches for how Android non-user interface threads can communicate user interface (UI) updates back to the UI thread.  As you have learned in this series, new threads to perform longer running work is the way to build applications and to avoid Android Not… Read More

Android Non-UI to UI Thread Communications (Part 4 of 5)

In parts 1-3 of this series, I have explored three different means for an Android non-UI thread to communicate user interface updates to the UI thread. The links below are to the series posts. Part 1 Part 2 Part 3 In this fourth installment, I want to show you how to use a broadcasts and a broadcast receiver to provide non-UI to UI thread communications. Background non-UI thread to UI thread comms As background for those jumping into the middle… Read More

Android Non-UI to UI Thread Communications (Part 3 of 5)

Continuing my series on Android non-UI thread-to-UI thread communications, this post covers use of the Handler Framework to facilitate the communications.  See here for Part 1 and Part 2 of the series. Non-UI threads are not allowed to make updates to the UI.  Trying to do too much work (as defined as not allowing the user to interact with the UI for more than 5 seconds) on the UI thread leads to ANR errors.  In the first two posts, I showed how… Read More

Android Non-UI to UI Thread Communications (Part 2 of 5)

This is the second part of my series of blog posts on Android non-UI thread-to-UI thread communications. See here for the start of the series.  As a refresher, this series of posts is about how non-UI threads can communicate back to the UI thread in an Android application in order to update the user interface.  Non-UI threads are not allowed to make updates to the UI.  Trying to do too much work (as defined as not allowing the user to interact… Read More

Android Non-UI to UI Thread Communications (Part 1 of 5)

Android UI Thread and ANR On the Android platform, applications operate, by default, on one thread.  This thread is called the UI thread.  It is often called that because this single thread displays the user interface and listens for events that occur when the user interacts with the app. Developers quickly learn that if code running on that thread hogs that single thread and prevents user interaction (for more than 5 seconds), it causes Android to throw up the infamous Android… Read More

Writing Android Apps on an Android Device – AIDE

First a word for my sponsor It has been more than a couple of months since my last blog post.  For every seven years of employment, my company gives its employees a two month sabbatical.  I just spent my sabbatical traveling Australia and New Zealand!  Below are a couple of pictures from my trip – one of Uluru in Australia and one of the Fox Glacier in New Zealand (If you look close you can see a few dots on the lower… Read More

Spring Framework’s WebDataBinder

Last week, I was just outside our nation’s capital teaching Spring Web MVC Framework to a wonderful group of people working for the National Institute of Health (NIH).  They are getting ready to move a collection of Struts 1 projects to Spring Web MVC.  Some questions and discoveries around Spring Web MVC’s @InitBinder operations seemed a good fit for this week’s post. Spring Web MVC Command Beans Part of my Spring MVC class is dedicated to teaching students how to… Read More

Intertech’s Complete Raspberry Pi Materials – Lab 9

Almost there!  All month, Intertech has been giving away the class material’s to the Complete Raspberry Pi training class and today I present you with Lab 9 of 10. These last two labs are pretty cool!  In these last two labs, you hook up your Pi to some sensors to create a home weather kit. In particular, in Lab 9, you attach a photo cell sensor (shown in the picture here) to your Pi via breadboard.  A photocell is basically a… Read More

Intertech’s Complete Raspberry Pi Materials – Lab 8

            Today’s give away lab is a continuation of Lab 7′s simulated LED stoplight lab.  In today’s lab, you use a Java program and a Java library (Pi4J) to get feedback from a switch (what is called a momentary switch – shown above), to turn the stop light on and off.  Specifically in this lab, you: Connect a momentary switch to the breadboard. Explore a program to get input from a momentary switch connected by… Read More