Xamarin. Android 應用程式基本概念Xamarin.Android Application Fundamentals

本節提供開發人員在開發 Android 應用程式時需要注意的一些常見工作或概念的指南。This section provides a guide on some of the more common things tasks or concepts that developers need to be aware of when developing Android applications.

協助工具選項Accessibility

此頁面說明如何根據協助工具檢查清單,使用 Android 協助工具 api 來建立應用程式。This page describes how to use the Android Accessibility APIs to build apps according to the accessibility checklist.

瞭解 Android API 層級Understanding Android API Levels

本指南說明 Android 如何使用 API 層級來管理不同 Android 版本的應用程式相容性,並說明如何設定 Xamarin Android 專案設定,以在您的應用程式中部署這些 API 層級。This guide describes how Android uses API levels to manage app compatibility across different versions of Android, and it explains how to configure Xamarin.Android project settings to deploy these API levels in your app. 此外,本指南也會說明如何撰寫處理不同 API 層級的執行時間程式碼,並提供所有 Android API 層級的參考清單、版本號碼(例如 Android 8.0)、Android 程式碼名稱(例如 Oreo)和組建版本代碼。In addition, this guide explains how to write runtime code that deals with different API levels, and it provides a reference list of all Android API levels, version numbers (such as Android 8.0), Android code names (such as Oreo), and build version codes.

Android 中的資源Resources in Android

本文介紹 Xamarin 中 Android 資源的概念,並說明如何使用它們。This article introduces the concept of Android resources in Xamarin.Android and documents how to use them. 其中涵蓋如何使用 Android 應用程式中的資源來支援應用程式當地語系化,以及多個裝置,包括各種不同的螢幕大小和密度。It covers how to use resources in your Android application to support application localization, and multiple devices including varying screen sizes and densities.

活動生命週期Activity Lifecycle

活動是 Android 應用程式的基本組建區塊,而且可以存在於許多不同的狀態。Activities are a fundamental building block of Android Applications and they can exist in a number of different states. 活動生命週期從具現化開始,並以銷毀結束,並在之間包含許多狀態。The activity lifecycle begins with instantiation and ends with destruction, and includes many states in between. 當活動變更狀態時,會呼叫適當的生命週期事件方法,通知活動即將發生的狀態變更,並允許它執行程式碼以適應該變更。When an activity changes state, the appropriate lifecycle event method is called, notifying the activity of the impending state change and allowing it to execute code to adapt to that change. 本文將探討活動的生命週期,並說明活動在每個狀態變更期間的責任,使其成為運作正常且可靠的應用程式的一部分。This article examines the lifecycle of activities and explains the responsibility that an activity has during each of these state changes to be part of a well-behaved, reliable application.

當地語系化Localization

本文說明如何藉由翻譯字串和提供替代影像,將 Xamarin 當地語系化為其他語言。This article explains how to localize a Xamarin.Android into other languages by translating strings and providing alternate images.

服務Services

本文涵蓋 Android 服務,這是 Android 元件,可讓您在背景中完成工作。This article covers Android services, which are Android components that allow work to be done in the background. 其中說明服務適用的各種不同案例,並示範如何同時執行這些作業,以進行長時間執行的背景工作,以及提供介面來進行遠端程序呼叫。It explains the different scenarios that services are suited for and shows how to implement them both for performing long-running background tasks as well as to provide an interface for remote procedure calls.

廣播接收器Broadcast Receivers

本指南涵蓋如何在 Xamarin 中建立和使用廣播接收器,這是回應全系統廣播的 Android 元件。This guide covers how to create and use broadcast receivers, an Android component that responds to system-wide broadcasts, in Xamarin.Android.

權限Permissions

您可以使用內建在 Visual Studio for Mac 或 Visual Studio 中的工具支援,來建立和新增 Android 資訊清單的許可權。You can use the tooling support built into Visual Studio for Mac or Visual Studio to create and add permissions to the Android Manifest. 本檔說明如何在 Visual Studio 和 Xamarin Studio 中新增許可權。This document describes how to add permissions in Visual Studio and Xamarin Studio.

圖形和動畫Graphics and Animation

Android 提供非常豐富且多樣化的架構,可支援2D 圖形和動畫。Android provides a very rich and diverse framework for supporting 2D graphics and animations. 本檔將介紹這些架構,並討論如何建立自訂圖形和動畫,並在 Xamarin Android 應用程式中使用它們。This document introduces these frameworks and discusses how to create custom graphics and animations and use them in a Xamarin.Android application.

CPU 架構CPU Architectures

Xamarin 支援數種 CPU 架構,包括32位和64位的裝置。Xamarin.Android supports several CPU architectures, including 32-bit and 64-bit devices. 本文說明如何將應用程式的目標設為一或多個支援 Android 的 CPU 架構。This article explains how to target an app to one or more Android-supported CPU architectures.

處理旋轉Handling Rotation

本文說明如何處理 Xamarin. Android 中的裝置方向變更。This article describes how to handle device orientation changes in Xamarin.Android. 其中涵蓋如何使用 Android 資源系統,自動載入特定裝置方向的資源,以及如何以程式設計方式處理方向變更。It covers how to work with the Android resource system to automatically load resources for a particular device orientation as well as how to programmatically handle orientation changes. 然後,它會描述裝置旋轉時維護狀態的技術。Then it describes techniques for maintaining state when a device is rotated.

Android 音訊Android Audio

Android OS 為多媒體提供廣泛的支援,同時包含音訊和影片。The Android OS provides extensive support for multimedia, encompassing both audio and video. 本指南著重于 Android 中的音訊,並說明如何使用內建的音訊播放機和錄製器類別,以及低層級的音訊 API 來播放和錄製音訊。This guide focuses on audio in Android and covers playing and recording audio using the built-in audio player and recorder classes, as well as the low-level audio API. 它也涵蓋了使用其他應用程式廣播的音訊事件,讓開發人員可以建立效能良好的應用程式。It also covers working with Audio events broadcast by other applications, so that developers can build well-behaved applications.

通知Notifications

本節說明如何在 Xamarin 中執行本機和遠端通知。This section explains how to implement local and remote notifications in Xamarin.Android. 其中說明 Android 通知的各種 UI 元素,並討論與建立和顯示通知相關的 API。It describes the various UI elements of an Android notification and discusses the API's involved with creating and displaying a notification. 針對遠端通知,會說明 Google 雲端通訊和 Firebase 雲端通訊。For remote notifications, both Google Cloud Messaging and Firebase Cloud Messaging are explained. 包含逐步解說和程式碼範例。Step-by-step walkthroughs and code samples are included.

觸控Touch

本節說明如何在 Android 上執行觸控手勢的概念和詳細資料。This section explains the concepts and details of implementing touch gestures on Android. 觸控 Api 的引進和說明,接著流覽手勢辨識器。Touch APIs are introduced and explained followed by an exploration of gesture recognizers.

HttpClient 堆疊與 SSL/TLSHttpClient Stack and SSL/TLS

本節說明適用于 Android 的 HttpClient 堆疊和 SSL/TLS 實作為選取器。This section explains the HttpClient Stack and SSL/TLS Implementation selectors for Android. 這些設定會決定您的 Xamarin Android 應用程式將使用的 HttpClient 和 SSL/TLS 執行。These settings determine the HttpClient and SSL/TLS implementation that will be used by your Xamarin.Android apps.

撰寫回應式應用程式Writing Responsive Applications

本文討論如何使用執行緒,將長時間執行的工作移至背景執行緒,以保持 Xamarin 應用程式的回應。This article discusses how to use threading to keep a Xamarin.Android application responsive by moving long-running tasks on to a background thread.