Of Code and Me

Somewhere to write down all the stuff I'm going to forget and then need

Setting child divider on an ExpandableListView causes weird flashing overlay on some Samsung phones November 29, 2011

Filed under: Android,Error — Rupert Bates @ 2:22 pm

This is a weird niche bug which I’m documenting here in case I need it in future.

Affected devices:
I have only seen it occur on a Samsung Galaxy S2 but I’m guessing it probably happens on any 2.x Samsung device running TouchWiz (it doesn’t happen on the Nexus S)

Steps to reproduce:
Create an activity with an ExpandableListView and set the childDivider property of the ExpandableListView to any colour, say red for ease of viewing


<ExpandableListView android:id="@+id/pageBundles"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:childDivider="@color/red"
                        android:cacheColorHint="@color/white"/>

Now if you scroll the list for a while, particularly if you sort of wiggle it up and down quickly and then let it go the list will be completely covered by a solid block of the colour specified in the childDivider property. This will remain for a few seconds and then disappear.

To fix this issue just remove the childDivider property setting

 

Speaking at JAX London 2011 October 1, 2011

Filed under: Android,guardian.co.uk,Java — Rupert Bates @ 5:15 pm

I am going to be giving a talk about the development of the recently released Guardian app for Android at the Jax 2011 conference.
The session is on the 2nd of November, more details here

 

Guardian App On Android V 1.0 September 7, 2011

Filed under: Android,guardian.co.uk — Rupert Bates @ 2:58 pm

Finally! The project I’ve been working on for the last 5 months goes live…
https://market.android.com/details?id=com.guardian
And:
http://www.guardian.co.uk/help/insideguardian/2011/sep/07/guardian-android-app

 

How to save the position of a ScrollView when the orientation changes in Android July 28, 2011

Filed under: Android,Coding — Rupert Bates @ 2:29 pm

To save and restore the scroll position of a ScrollView when the phone orientation changes you can do the following:
Save the current position in the onSaveInstanceState method:

    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putIntArray("ARTICLE_SCROLL_POSITION",
                new int[]{ mScrollView.getScrollX(), mScrollView.getScrollY()});
    }

Then restore the position in the onRestoreInstanceState method, note that we need to post a runnable to the ScrollView to get this to work:

    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
        final int[] position = savedInstanceState.getIntArray("ARTICLE_SCROLL_POSITION");
        if(position != null)
            mScrollView.post(new Runnable() {
                public void run() {
                    mScrollView.scrollTo(position[0], position[1]);
                }
            });
    }
 

Get your Android application to fill up the whole screen on a tablet June 24, 2011

Filed under: Android — Rupert Bates @ 7:30 pm

When I got hold of a Android 3 tablet, the first thing I did was to run one of the apps I’ve developed on it to see how it looked. I was surprised to see that it just ran in a little window, much like IPhone apps do on an IPad.

Fortunately getting the app to fill the whole screen just required the following line after the <application> section in my AndroidManifest.xml:


<uses-sdk  android:targetSdkVersion="9"/>

 

Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES] error when trying to install an app in Android June 11, 2011

Filed under: Android,Error — Rupert Bates @ 8:34 pm
             Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]

This error occurs when you try to install an app via ADB and there is already another version of the same app which was installed from a different development machine.

To get round it uninstall the previous version and rerun the install.

 

Motorola Xoom connects to wi-fi but not the internet – How to fix it May 7, 2011

Filed under: Android,Error,Xoom — Rupert Bates @ 9:01 am

I’ve recently got a Motorola Xoom tablet and when I first tried to connect to the internet at home was surprised and annoyed to find that although it would connect to my wifi no problem, it could not get an internet connection.

It seems that the problem lies in the DHCP interaction between the Xoom and my wireless router which results in the Xoom not picking up gateway information from the router. The solution was to configure a static IP address for the Xoom.

To do this do the following:

  • Go into Settings, then ‘Wireless & networks’ then ‘Wi-Fi settings’
  • Find your wi-fi network in the list and press and hold then select ‘Modify network’ from the pop up
  • Scroll down to the ‘IP settings’ drop down and switch it from DHCP to Static
  • In the ‘IP address’ box enter the same IP address which is shown higher up the same form
  • In the ‘Gateway’ box you will need to put the IP address of your router, to find this out I opened a command prompt window on a PC on the same network and typed ipconfig¬†this will give you a Default gateway address which is what you need
  • In the the ‘Network prefix length’ box put 24 (this assumes the subnet mask from ipconfig is 255.255.255.0)
  • Finally in the ‘DNS 1’ box put the same IP you put in the Gateway box
Now click Save, disconnect and reconnect from the network and when you are reconnected you should have internet access.
Note: There has been some discussion around the save button being greyed out, resulting in the following:
“the save option is usually greyed out until you have entered your password at the top, network prefix, and dns 1. make sure you have entered these things or else it wont let you save. also make sure you have entered them and they are not just grey. “