针对 Android(Go 版本)进行开发
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
构建在 Android(Go 版本)设备上使用的应用时需要特别注意性能优化和对资源的使用。针对 Android(Go 版本)进行应用开发时,需要了解两个主要组件:操作系统 (OS) 和 Google Play 商店。
操作系统兼容性
针对 Android(Go 版本)开发应用时,最好开发操作系统感知型应用。我们所说的操作系统感知型应用是指,应用可以检测并适应 Android(Go 版本)用户。例如,isLowRamDevice()
标志可让应用检测自己是否是在低内存设备上运行,并以相应的方式运行。
了解用户的操作系统后,就可以限制 Go 设备上无法使用的某些功能,例如在其他应用上显示或使用多屏幕。如需查看 Go 上的应用限制的完整列表,请参阅与 Android 的区别。
启动后 RAM 的重要性
在某些情况下,进程和任务可以在后台持续运行,这些进程和任务可能来自系统或是从 Play 商店安装的应用。例如,当用户设备重启时,会启动 BOOT_COMPLETED
广播,设备上运行的许多服务或应用可能都需要此广播。这种持续的广播可能会导致应用无法启动,或者由于设备内存不足而导致应用的前台任务失败。
用户设备上的所有应用都会直接影响内存可用性。如果这些应用启动广播或服务,则 Android(Go 版本)应用必须查询用户设备上的启动后系统内存可用性,因为这会直接影响最终用户体验。
开发者选择
当开发者为应用做出选择时,应确保应用能够在 Android(Go 版本)的限制下运行。有时,允许用户直接停用某项特定功能是不够的,因为应用可能需要启用这些功能才能正常运行。如需查看 Android(Go 版本)上最常见限制的列表,请参阅与 Android 的区别。
Google Play 商店
Google Play 商店在 Android(Go 版本)和 Android 平台上的外观、风格和操作方式都相同。不过,在 Go 设备上,Play 商店可能会推荐针对 Android(Go 版本)优化过的应用。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Develop for Android (Go edition)\n\nBuilding applications for use on Android (Go edition) devices requires special\nattention to performance optimizations and resource usage. There are two main\ncomponents to understand when building for Android (Go edition): the operating\nsystem (OS) and the Google Play Store.\n\nOperating system compatibility\n------------------------------\n\nIt's very important to develop an *OS-aware* app when developing for Android\n(Go edition). By OS-aware, we mean that your app can detect and adapt to\nAndroid (Go edition) users. For instance, the\n[`isLowRamDevice()`](/reference/android/app/ActivityManager#isLowRamDevice())\nflag enables your app to detect whether it is running on a low-memory device\nand behave accordingly.\n\nBy knowing the OS of your users, you can limit certain functionalities that\naren't available on Go devices, like drawing over other apps or using\nmulti-display. For a full list of app limitations on Go, see\n[Differences from Android](/guide/topics/androidgo#differences-from-android).\n\n### Importance of POST-boot RAM\n\nThere are instances where processes and tasks can run persistently in the\nbackground, either from the system or apps from the Play Store. For example,\nwhen a device restarts, there is a `BOOT_COMPLETED` broadcast that might be a\nrequirement from many services or apps running on a user's device. This\npersistent broadcast can lead to apps not launching, or having\nforeground tasks fail, due to low memory on a device.\n\nAll apps on a user's device directly impact memory availability. If\nthese apps initiate broadcasts or services, then it becomes mandatory for\nAndroid (Go edition) apps to query post-boot system memory availability on a\nuser's device as it directly impacts the end-user experience.\n\n### Developer choices\n\nWhen it comes to making choices for your application as a developer, you should\nensure your app can run with Android (Go edition) limitations in mind.\nSometimes, allowing users to simply disable a specific feature is not enough,\nas apps might require those features to be enabled to run properly. For a list\nof the most common limitations on Android (Go edition), see\n[Differences from Android](/guide/topics/androidgo#differences_from_main_android).\n\nGoogle Play Store\n-----------------\n\nThe Google Play Store looks, feels, and operates the same on both Android\n(Go edition) and Android. However, on Go devices, the Play Store may recommend\napps that are optimized for Android (Go edition)."]]