Tag Archives: Problem

Android WebView flicker when using hardware acceleration on Android 3.0+

There is an Android bug where WebViews may present an ugly flicker when being used on 3.0+ devices with Hardware Acceleration enabled. I was busy with an update to an Android app I’m working on which makes use of a WebView that slides in and out (using this awesome Sliding Menu library), when I noticed the *delightful* surprise when sliding the WebView back in:

Not ideal, is it?

Not ideal, is it?

As much as I can’t believe this kind of bug still exists, especially considering it seems to have been around for some time, it lives with us and thus we need to use some kind of workaround.  I immediately turned to SO for help and found a possible workaround:

WebView “flashing” with white background if hardware acceleration is enabled (Android 3.0+)

The workaround involves using a method that is only available from API level 11 (HoneyComb), and considering my app is targeting a minimum level of 8 I used the following code:

/**
 * Initializes the WebView:
 * - Configures the WebView settings
 * - Adds a WebViewClient
 * - Custom config of the webview
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void initWebView()
{
	// Other init code
	
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
	{
		// This is added as a work-around for the flicker which occurs in Android 3.0+
		// when hardware acceleration is enabled:
		// http://stackoverflow.com/questions/9476151/webview-flashing-with-white-background-if-hardware-acceleration-is-enabled-an
		getWebView().setLayerType(View.LAYER_TYPE_SOFTWARE, null);
	}
}

So pick your poison: reduced performance or flickering?

Advertisements

UIRefreshControl bug in landscape mode.

The iOS UIRefreshControl provides a standard “pull-down-to-refresh” mechanism for certain UIScrollView classes such as UITableView and UICollectionView.

The UIRefreshControl, however, has a bug in landscape mode on the iPhone whereby there isn’t enough room to pull down to trigger the refresh mechanism. Go here for more information on the bug and possible workarounds.

I ended up using the following code in my UIScrollViewDelegate implementation (both UITableViewDelegate and UICollectionViewDelegate conform to UIScrollViewDelegate):

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    if (self.collectionView.contentOffset.y < -80 && ![self.pullDownRefreshControl isRefreshing])
    {
        [self.pullDownRefreshControl beginRefreshing];
        // perform refresh operation...
    }
}

The “pull-down-to-refresh” animation isn’t as slick, but it’s a good workaround for now.

Evernote for Android Sync Failure

Image

I use Evernote for Android on a regular basis to keep track of notes or random things of interest. When updating to v4.4.2 for Android, however, the application kept failing to sync with my account. I’m not sure if the error was necessarily related to the new version, however, I found that the solution was to login on the web and empty the trash. Once I had done that I signed out and signed back in using the mobile app and the syncing worked again.