Android
Android files
Common tasks HowTo
Binding a List to a data cursor
icon sizes and design
Android icon examples
or on local drive: android-sdk-linux_86/platforms/android-8/data/res
Hierarchy Viewer
layoutopt tool
Layout Objects
Example Views
R.Stylable class
RelativeLayout example
Android graphical widget guide
Tab examples
Table example
Table example w/divider
Table row lines hack
Table rounded border
Table rounded border example 2
WebView - show simple content within an Activity
Service
Manifest service element
Message
Notification
Intent guide
Intent
Intent example
Security permissions
A feature can be protected by at most one permission.
Data storage
Shared Preferences
Store private primitive data in key-value pairs.
Internal Storage
Store private data on the device memory.
External Storage
Store public data on the shared external storage.
SQLite Databases
Store structured data in a private database.
Content providers
Must be implemented thread-safe.
Call ContentResolver.notifyChange() to notify listeners when data changes.
Strongly recommended that content providers implement fine-grained URI permissions and declare that they support it through the android:grantUriPermissions attribute or
Application location
Specified in manifest with android:installLocation
The default is internalOnly, set to to auto to allow external installation and the user to move it.
Don't use android:maxSdkVersion, it is not necessary.
Memory leaks typically: keeping a long-lived reference to a Context
if you leak the Context, you leak a lot of memory. Leaking an entire activity can be really easy if you're not careful.
For Input Method Framework (IMF): The most important thing for an application to do is to use the new android:inputType attribute on each EditText.
Threading
The main thread is the UI thread, all UI updates must be on the main thread.
Use AsyncTask to perform background operations and callback to update UI thread when completed without having to manipulate threads and/or handlers.
Thread and Handler example
Instead of doing intensive tasks via child threads (as the life of a BroadcastReceiver is short), your application should start a Service if a potentially long running action needs to be taken in response to an Intent broadcast. As a side note, you should also avoid starting an Activity from an Intent Receiver, as it will spawn a new screen that will steal focus from whatever application the user is currently has running. If your application has something to show the user in response to an Intent broadcast, it should do so using the Notification Manager.
Use existing styles and themes - blend in.
Conserver battery power
Hide window title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
Notification example:
Launch web page from textview link:
autolink, setMovementMethod, non-HTML
Four ways
Simple text link
Common tasks HowTo
Binding a List to a data cursor
icon sizes and design
Android icon examples
or on local drive: android-sdk-linux_86/platforms/android-8/data/res
Hierarchy Viewer
layoutopt tool
Layout Objects
Example Views
R.Stylable class
RelativeLayout example
Android graphical widget guide
Tab examples
Table example
Table example w/divider
Table row lines hack
Table rounded border
Table rounded border example 2
WebView - show simple content within an Activity
Service
Manifest service element
Message
Notification
Intent guide
Intent
Intent example
Security permissions
A feature can be protected by at most one permission.
Data storage
Shared Preferences
Store private primitive data in key-value pairs.
Internal Storage
Store private data on the device memory.
External Storage
Store public data on the shared external storage.
SQLite Databases
Store structured data in a private database.
Content providers
Must be implemented thread-safe.
Call ContentResolver.notifyChange() to notify listeners when data changes.
Strongly recommended that content providers implement fine-grained URI permissions and declare that they support it through the android:grantUriPermissions attribute or
Application location
Specified in manifest with android:installLocation
The default is internalOnly, set to to auto to allow external installation and the user to move it.
Don't use android:maxSdkVersion, it is not necessary.
Memory leaks typically: keeping a long-lived reference to a Context
if you leak the Context, you leak a lot of memory. Leaking an entire activity can be really easy if you're not careful.
For Input Method Framework (IMF): The most important thing for an application to do is to use the new android:inputType attribute on each EditText.
Threading
The main thread is the UI thread, all UI updates must be on the main thread.
Use AsyncTask to perform background operations and callback to update UI thread when completed without having to manipulate threads and/or handlers.
Thread and Handler example
Instead of doing intensive tasks via child threads (as the life of a BroadcastReceiver is short), your application should start a Service if a potentially long running action needs to be taken in response to an Intent broadcast. As a side note, you should also avoid starting an Activity from an Intent Receiver, as it will spawn a new screen that will steal focus from whatever application the user is currently has running. If your application has something to show the user in response to an Intent broadcast, it should do so using the Notification Manager.
Use existing styles and themes - blend in.
Conserver battery power
Hide window title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
Notification example:
Notification notification = new Notification(R.drawable.daisy_48px_0, "daisy", System.currentTimeMillis());
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, BackgroundService.class), 0);
CharSequence test = getText(R.string.hello);
notification.setLatestEventInfo(this, getText(R.string.hello), test, contentIntent);
NotificationManager nm = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);
nm.notify(R.string.hello, notification);
Launch web page from textview link:
autolink, setMovementMethod, non-HTML
Four ways
Simple text link
Comments