Android Platform Samples

repository·main·Indexed 23 days ago

https://github.com/android/platform-samples

A collection of Android OS platform API samples designed to showcase specific functionalities in isolation. The repository includes demonstrations for Accessibility, Camera2 API (including UltraHDR), Connectivity (BLE, Companion Device Manager, Telecom SDK, and UWB), Graphics (PdfRenderer and UltraHDR), Location, Privacy, Storage, and User-interface.

Tokens
11.6K
Snippets
14
Records
77
Agent score
82%

What's inside android-platform-samples

  1. Overview of Jetpack WindowManager

    main
    The Jetpack WindowManager library provides a common API surface for accessing Window Manager features across different Android platform versions. It is designed to help applications support new device form factors, such as foldable devices, by providing consistent access to display information and window features. This sample specifically focuses on implementing support for foldables.
  2. Overview of AppWidgets samples

    main

    This module provides demonstration code for building Android AppWidgets using two primary approaches:

    1. RemoteViews and New Widgets APIs: Demonstrates the APIs introduced in Android 12 (API level 31) along with core-remoteviews for building engaging widgets.
    2. Jetpack Glance: Demonstrates how to use the Jetpack Glance framework to build app widgets.

    Use these samples in conjunction with the official App widget guides.

  3. Overview of the Telecom Sample

    main

    The Telecom Sample demonstrates how to integrate the Jetpack Telecom SDK to perform audio and/or video calls using the Android Telecom stack.

    Note on Call Simulation: This sample simulates a caller application. It does not make actual phone calls; instead, it uses AudioLoopSource to capture device audio and loop it back to the active endpoint (such as the speaker) to simulate a call environment.

  4. Overview of Quick Settings tiles

    main

    Quick Settings are interactive tiles displayed in the status bar drawer above the notification shade. Apps can implement custom tiles that users can add to their Quick Settings panel.

    This specific sample focuses on the most common implementation: a tile that users tap to toggle between an active and inactive state. For more complex tile types, refer to the official Android documentation on Create custom Quick Settings tiles for your app.

  5. Overview of Privacy - Data minimization samples

    main

    This module provides sample implementations demonstrating how to implement data minimization principles in Android applications. Specifically, it focuses on two areas:

    1. Minimizing Package Visibility: Using Package Visibility APIs to limit the visibility of other installed apps on the device.
    2. Using Appropriate Identifiers: Implementing best practices for identifiers to avoid the use of non-resettable device identifiers.

    Refer to src/main/java/com/example/platform/privacy/data/PackageVisibility.kt for specific implementation details regarding package visibility.

  6. Overview of the Android Ultra-wideband (UWB) sample

    main

    This sample project demonstrates the capabilities of the Android UWB Jetpack library. It provides concrete code examples for integrating UWB into Android applications, focusing on ranging and device interaction.

    Key features demonstrated include:

    • Device compatibility: Checking if a device supports UWB hardware.
    • Device Discovery: Using an Out-of-Band (OOB) mechanism (specifically the Nearby Connections API) to discover devices, as UWB does not support native discovery.
    • Simple Ranging: Displaying the distance between a controller and a controlee.
    • Device Control: Simulating proximity-based actions, such as opening a door lock.
    • Share Media: Demonstrating media file transfers using the selected OOB mechanism when devices are in close proximity.
    • Role Selection: Configuring which device acts as the Controller or the Controlee.
  7. Explore Storage API samples

    main

    This directory contains sample implementations demonstrating how to use Android Storage APIs. The samples are designed to be independent of one another and provide simplified use cases for learning purposes.

    Available samples:

    • MediaStore Query: Demonstrates how to query the MediaStore to retrieve media files.
    • Selected Photos Access: Demonstrates how to handle partial access to photos (the Selected Photos Access feature).

    For comprehensive documentation and production-ready implementation details, refer to the official Android Data Storage guide.

  8. Understand the Platform Samples app module

    main

    The app module serves as the central launch point for the Android Platform Samples repository. It uses the casa-android framework to wire various individual samples together into a single application.

    Note for developers: The code within this specific module is infrastructure-related and is not intended to be modified or used directly when working on individual samples. You should focus on the specific sample modules rather than the app module itself.

  9. Explore Drag and Drop implementation samples

    main

    This directory contains several independent samples demonstrating different ways to implement Drag and Drop functionality in Android. Each sample is self-contained and can be run independently.

    Available implementation patterns:

    • Views-based: Uses onLongClickListener and DragListener callbacks for basic implementation.
    • Multi-Window: Demonstrates drag-and-drop functionality across different applications.
    • Jetpack Library: Uses the Jetpack Drag and Drop Library for implementation.
    • Jetpack Compose: Showcases drag-and-drop implementation specifically for Compose-based UIs.
    • Rich Media: Demonstrates handling rich media using the RichContentReceiver unified API, which works across drag-and-drop, keyboard, and clipboard operations.