Interesting Android Networking Libraries





Posted in Uncategorized | Leave a comment

Android SQLite3 corruption


Caused by: android.database.sqlite.SQLiteCantOpenDatabaseException: unable to open database file
	at android.database.sqlite.SQLiteDatabase.dbopen(Native Method)
	at android.database.sqlite.SQLiteDatabase.openDatabase(
	at android.database.sqlite.SQLiteDatabase.openDatabaseEnc(
	at android.database.sqlite.SQLiteDatabase.openOrCreateDatabaseEnc(
	at android.content.ContextWrapper.openOrCreateDatabase(
	at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(

Things that can go wrong

Android deletes corrupt databases

Best Practices

Posted in Uncategorized | Leave a comment


Good Sites

Thrust Calcs

Posted in Uncategorized | Tagged | Leave a comment



Manifest can declare icons and description — android:icon=”@/drawable/XXXX”
always set android:exported=”true”
permissions are possible
Plugins could also be Activities
Also service could launch activity
IntentSerivce is Asynchronous


use self documenting names like OptionalCopyright
get metadata with getPackageManager() with GET_META_DATA flag

Plugin UUID

Should use

Plugin Registration

Store information in content provider

Content Provider

Stores meta data from plugins read from manifest
Faster than reading manifest directly
Get plugin assets from the assets manager store pointers in the provider
Contract Pattern in android.provider class is helpful

Contract Classes

Should be in a library so developers can use in their projects


Can have multiple categories as Intent Filters
Data must be URI
Use parcelable extra to send more data
Use MIME types, start with vnd
choose startService() vs startActivity()


used for callback to main app
IPC Service
can access shared preferences with MODE_MULTI_PROCCESS flag and explicit name

Posted in Uncategorized | Tagged | Leave a comment

Open GL Notes

NIO Buffers (New I/O)

Standard for Android

Vertex Attributes

Setup – Give expecations
Can have colors and/or textures(image)

State Machine

States stay active until next state is called or context is lost
Current Texture

Right Hand Rule

Middle Finger Up
Middle Finger — Z
Fore Finger — Y
Thumb — X


4×4 matrix transforms verts (understanding not important)
Can be combined example: rotate and re-size and move


Camera is fixed
Vertices move to look like camera is moved


Object Space Center is (0,0,0)
Model Space
View Space

Projection Functions

GLU class can control perspective
zNear and zFar will control resolution and what can be seen
Orthographic – for clipping (near and far have no effect)

View/Camera Functions


Must be power of two (faster)
Shrink texture offline then expand in code. It will look bad to the artist.
Mipmaping will auto re-sample textures (must be turned on)

2D Rendering

Batching — should use as few draw calls as possible
Use array of many vertices
Texture switching can slow things down
Put everything in one large texture if possible (called an atlas) texturePacker tool

Store models with .obj
Create with Blender or Maya

Posted in Uncategorized | Tagged | Leave a comment

Creating Lightweight SDKs

Should Be

Must be stable
Don’t take features away
Catch all exceptions only throw if in debug mode
Should create a test app
Easy to use

Interacting with Users without Activity

Use Toasts – customized
launch browser


Avoid if possible
Check permissions in runtime

Java Docs

Use them


use @Deprecated annotation

Binary Footprint (Size)

Average game size 40MB
Average App 6MB

Reducing Size

Use ProGuard shrinks by 4% to 53% in practice
DexGaurd paid service specific to android (byte code level)

Startup Time

Don’t run on main thread

Network Usage

protobuf – fast server communication 700k, 100x faster

CPU Usage

Use exponential backoff
Only log in debug mode
Monitor with — adb shell top -m 10

Battery Usage

Optimize network transfers – use bundled transfers
PhoneStateListener – onDataActivity(int) to piggy back on existing data transfers

Posted in Uncategorized | Tagged | Leave a comment

App Marketing

Internet Marketing Funnel

Prospect – app discovery, letting them know the product exsists
Loyal Customer — buy addons
Advocate — good rating


User completes a goal i.e. purchase

Target Audience

Find by looking at similar apps – how many users do they have

Ranking Factors

Total installs
Active install %


Branded vs Keyword
Could use both
Can add * symbol to title

Keyword Research

Google Keyword Tool or AdWords Account — use exact term
Find best keyword for title
Find 20-40 target keywords for description
Don’t use keyword farms

Market Listing

Icon is important
Need a great winning first sentence
Landing page optimization can make a difference — Can use Google Website Optimizer
Add Call to Action — Install today to start your fun
Add testimonials
Reassure the user
Need promotional image — Makes a big impression on customers
Action Screenshots better than preferences — consider adding words to screenshots

YouTube Video

Lots of hits from Google Play website
Think movie trailer
Visualize themselves with your app and how their lives will change


Quality matters


  • Free to Paid
  • Win a game
  • Use app often
  • Rate the app

App quailty

Users only care about features they want
Users may give up if they can’t find what they want — make games easier to find

Google’s Conversion University

Good information on conversion


Track conversions
Use BIG BUTTON to go direct to market listing – Make it easy
Use referral tracking for website buttons
Tag URLs to website from other marketing

Paid Ads

Track to ROI – drop losers and keep winners
Pay Per Install
Pay Per Action
Can be used Test calls for actions

Hiring People

Out source
Contract from a spec
Part time
Full time – Best
Pay via Paypal mass pay
Have send daily email report
Hire One at a time
Exchange multiple communications before hiring
Use test task

Project Management



Release MVP – Minimum viable product

Getting More Comments

Releasing meaningful updates
Talk up your updates
Ask for comments

Enganging Users

Email newsletter – subscribe in app
Use auto-responders
MailChimp – Has reports
Respond to comments
Ask uses to take action
Leave a comment
Respond to Survey
Social Media
Help Desk — common questions and answers, macros, Zendesk

Internet Marketing

Get keywords
Make one page for each keyword
Market Samurai – To be the first page on Google you must beat the first page
Use Google webmaster tools
Post on blog every day or make new webpage
YouTube is Second largest search engine — Link needs to be first thing in your descriptions
TubeToolBox — good tool to find subscribers

Posted in Uncategorized | Tagged | Leave a comment

Android Touch Input

Notes from AnDevCon IV – Touch Input

Start with dispatchTouchEvent() flow down until consumed by a view
End back to Activity with onTouchEvent() <– only if not consumed, last in chain
OnTouchListener optional always called first
onInterceptTouchEvent() can grab touch events from children, passes ACTION_CANCEL to child
View group send touch events to children in reverse order of added order to match z order

After first event is consumed additional events are routed directly to the consumer
Must return true on all events if your view is interested in any events else all events will be routed directly to the activity

return super() when not returning true


Class contains constants for view identification
getScaledTouchSlop() < dragged movement

Touch Event Forwarding

Call targets dispatchTouchEvent() not onTouchEvent()
onInterceptTouchEvent() is a one time shot
View.onTouchEvent() does a lot of state management, call super() when in doubt
protect ACTION_MOVE with slop checks


touch down and up event contain pointer index
MotionEvent.getActionMasked() to auto mask events


ACTION_MOVE events can be batched
Latest is returned by standard methods – getX() getY()
getHistoricalXXX(int index) methods to get rest of events

ScaleGestureDetector looks for pinch (api 2.2+)


TouchDelegate job is to forward from parent to child *
For very small target
Can make a views touchable area large within bounds of parent view
ViewGroup.setTouchDelegate( new TouchDelegate(Rect bounds, View child);
When event is send to child view X Y is centered on child view

Posted in Uncategorized | Tagged , | Leave a comment

Android Concurrency

Notes from AnDevCon IV

Design for correctness upfront
Don’t leak Activities

Possible Solutions

Use threads when needing full control – must handle lifecycle
Non static inner class hold reference to activity
Don’t lock orientation as a solution
Use timeouts for I/O and HTTP
Check for interruption in CPU loops


Post results back to main UI
Good for lots of small tasks
Not bound to Activity
Bad for long running operations or network I/O
onPre and onPostExecute and onProgress run on main UI thread
can check isCancelled() from doInBackground()
Inconsistent in different API levels

Avoiding Activity Leaks

make it private static
Pass activity as WeakReference
Check Activity for null
cancel in onDestroy()
Managing a Handler could cause a leak


Put a single unit of work on a separate Thread
Delivers on the main thread
Continues work during a configuration change
Can monitor data source for change
API level 11+ or 4+ with compatibility library

Loader Usage

Sub class
Managed by LoaderManager
Implement callbacks
loadInBackground can block
Should never contain Activity instances
onLoadFinished called main UI thread
Loader callback can have Activity References


create call backs in onCreate
pass Loader ID


implementation of Loader


custom implementation
puts all work on a singleton Thread


add state to loader too determine if active

Tracking Multiple Loaders

Save loader id’s in onSaveInstanceState()
Read in onCreate()

Tracking Loader Work

use LocalBroadcastManager – part of compatibility library


queries content providers
Create LoaderCallback with Cursor type
onLoadFinished() use the data

Loaders with Asynchronous APIs

call API in loadInBackground()
use CountDownLatch to block loader thread
API listener should signal the latch

Not for Loaders

lots of small downloads
if needs to run after activity is complete


For very long running operations not tied to Activities
Independent of Activity
have own context
Can be “started” or “bound”

Started Services

can start and stop at any time running as long as needed
must stop the service
manage threading or use IntentService
must figure out how to send data to app


Single thread
only runs while work is available
must add to Manifest
override onHandleIntent(Intent) <– run in background
can pass parameters in Intent

Looper, Handler. HandlerThread

Handler schedules and executes work can receive messages and post runnable
Handler has access to single thread
HandlerThread convenience class for creating a new Thread with Looper
HandlerThread could be used as alternative to IntentService

Optimizing for Intermittent I/O

limit to one or two threads
if downloading large files use one thread
only one thread for file I/O per storage device
Runtime.getRuntime().availableProcessors() – 1 threads for CPU intense tasks


Android has all Java tools (Semaphore, BlockingQueue, etc)
Devices may delay using cores
Avoid polling loops at any cost – use callbacks or blocking
THREAD_PRIORITY_AUDIO sets to higher priority than UI
Compute Renderscript can offload heavy math to GPU

Posted in Uncategorized | Tagged | Leave a comment

AI Apps

Notes from AnDevCon IV
Artificial Intelligence (AI) and Intelligent Apps


Feature Extraction

What is AI?

Representation of human like capabilities in software
Systemic AI – Combining smaller AI systems that solve simple problems

Practical AI

Robot Control
Personalized Advertizing
Question Answering Systems
Automated news authoring

AI Models


Best AI Algorithms

Any – Difference in returns is small

Posted in Uncategorized | Tagged , , | Leave a comment