Category «Android Advanced Concepts»

Some material design features like the material theme and custom activity transitions are only available on Android 5.0 (API level 21) and above. However, you can design your apps to make use of these features when running on devices that support material design and still be compatible with devices running previous releases of Android. Define …

The following capabilities for drawables help you implement material design in your apps: Drawable tinting Prominent color extraction Vector drawables This lesson shows you how to use these features in your app. Tint Drawable Resources With Android 5.0 (API level 21) and above, you can tint bitmaps and nine-patches defined as alpha masks. You can …

This lesson describes how to use touch gestures to drag and scale on-screen objects, using onTouchEvent() to intercept touch events. Drag an Object If you are targeting Android 3.0 or higher, you can use the built-in drag-and-drop event listeners withView.OnDragListener, as described in Drag and Drop. A common operation for a touch gesture is to …

A multi-touch gesture is when multiple pointers (fingers) touch the screen at the same time. This lesson describes how to detect gestures that involve multiple pointers. Track Multiple Pointers When multiple pointers touch the screen at the same time, the system generates the following touch events: ACTION_DOWN—For the first pointer that touches the screen. This …

Alarms (based on the AlarmManager class) give you a way to perform time-based operations outside the lifetime of your application. For example, you could use an alarm to initiate a long-running operation, such as starting a service once a day to download a weather forecast. Alarms have these characteristics: They let you fire Intents at …

To avoid draining the battery, an Android device that is left idle quickly falls asleep. However, there are times when an application needs to wake up the screen or the CPU and keep it awake to complete some work. The approach you take depends on the needs of your app. However, a general rule of …

As shown in the previous lesson, you should begin loading your data with a CursorLoader in your implementation of onCreateLoader(). The loader then provides the query results to your Activity or FragmentActivity in your implementation ofLoaderCallbacks.onLoadFinished(). One of the incoming arguments to this method is aCursor containing the query results. You can use this object …

A CursorLoader runs an asynchronous query in the background against a ContentProvider, and returns the results to the Activity or FragmentActivity from which it was called. This allows the Activity or FragmentActivity to continue to interact with the user while the query is ongoing. Define an Activity That Uses CursorLoader To use a CursorLoader with …

This lesson shows you how to report the status of a work request run in a background service to the component that sent the request. This allows you, for example, to report the status of the request in an Activity object’s UI. The recommended way to send and receive status is to use a LocalBroadcastManager, …