Android: Fix possible array bounds errors