Android: Update to Postmortem Reports via email

With the addition of an Activity stack to my portmortem email reporter, it became apparent that relying on the garbage collector to restore the original exception handler was not an ideal solution. I have added a new method called restoreOriginalHandler() that should be called in your Activity class’s onDestroy() method.

public class MyActivity extends Activity {
    protected PostMortemReportExceptionHandler mDamageReport = new PostMortemReportExceptionHandler(this);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mDamageReport.initialize();
    }

    @Override
    protected void onDestroy() {
        mDamageReport.restoreOriginalHandler();
        mDamageReport = null;
        super.onDestroy();
    }
}

Original post, updated.

Updated code link (copied from original post):
Full Source

Android: Sharing Resources in Eclipse

The resources of an Android project are difficult to share between projects. In order to create a common library of widgets that reference resources is no simple task and yet is something quite desirable. Creating a “Save File” generic dialog and being able to share it amongst various Android projects not only as an Activity, but as a class ancestor that can be descended from and modified for various specialized cases is a highly desirable feature. I am used to having such a feature in the past with other languages (like Delphi’s Forms) and have been frustrated with Android projects in Eclipse. The various techniques available to potentially share resources all have their fatal flaws. Continue reading

findViewById slow inside ListView adapters

I was reading an article over on charlie.collins’s blog about using a ViewHolder class to cache the results of a findViewById() when used inside the getView() of a list’s adapter. I gave his recommendation a try and I did notice a speed improvement in my app so the observation that findViewById() is a performance hit has enough merit to go out of your way to enable some kind of caching mechanism.

While Charlie went the route of creating a class to hold the various views he was interested in, I decided to take a slightly different approach and make use of the alternative setTag(int, Object) function instead. Continue reading

Working with Android Libraries and shared code

One of the issues that has irked me for quite a while is the fact that there is no easy way to work with a set of shared code between apps in Eclipse that simultaneously gives me instant access to modifying the shared library and also the flexibility of including only the pieces of it that are needed while excluding the rest. Android Library Projects are a big step forward in helping to create a set of shared resources as well as code, but they still lack the flexibility of only including just what you need (not to mention Library Projects cannot use other Library Projects). Continue reading

Android 2.3 SDK and Formatted String Resources

The Android 2.3 SDK in Eclipse enforces the optional Argument Index if you use multiple arguments inside a string resource.

Still OK: 

1
"Hello %s."

Flagged as an error: 

1
"Hello $s, %d days have gone by."

Google is taking issue with implicit argument ordering on the grounds that it is not Best Practice to leave it up to the translators to place the argument specifiers if they need to shift around the order due to language grammar. While I feel that taking away Continue reading

Trouble browsing the web?

I recently helped out a guildie with a strange problem.  He couldn’t browse the web using Internet Explorer, nor play WoW, but he could log into Vent just fine.  My first thought was that he got a virus that prevented browsing and started giving him suggestions on how to clean his system and recommending borrowing a friend’s computer to facilitate it.  While giving out this advice, it struck me to try one more thing before writing this off as a malicious virus (which is usually the case when something like this occurs, sadly).

I quickly opened a CLI box and did a quick ping on www.google.com to find out it’s IP address.  I then relayed that address over Vent and had him type it into the browser address box.  Up came Google for him!  What did this tell me?  It told me that his computer was NOT infected with a virus (thankfully!) and that his ISP’s Domain Name Servers (DNS) went offline which meant he was trying to browse the internet blind (meaning he could only use IPs and not their friendly names).   Luckily, there are public DNS that can be used, but the process to tell your computer to use them is anything but easy.  I figured it would be a good idea to put a few resources together to help others out in such a situation, if not directly, at least a friend can help them out by having this information at hand.  I walked him through setting up his computer to use Google’s public DNS and afterwards he was able to surf the web and play WoW as if nothing was wrong.  Woot!

Google runs a public DNS on:
Primary: 8.8.8.8
Alternate: 8.8.4.4

OpenDNS also runs public DNS and seems a bit more responsive:
Primary: 208.67.222.222
Alternate: 208.67.220.220

Now for the hard part… instructions on how to tell your network connection to use these public servers rather than whatever your ISP gave you.  Thankfully, OpenDNS has some very good instructions with images to help you with each OS.

Configure MS Win7

Configure MS Vista

Configure Mac OS X 10.5 (Leopard)

Configure Max OS X 10.4 (Tiger)

Other OS instructions can be found here.

Props go out to OpenDNS for both supplying public servers and some very handy instructions for setting up your system to use them.