與其他應用程式互動
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 應用程式通常會提供多項活動。每項活動都會顯示使用者介面,讓使用者執行特定工作 (例如查看地圖或拍照)。為了讓使用者順利進行各種活動,應用程式必須使用 Intent
來定義應用程式的「意圖」以執行特定功能。當您利用 startActivity()
這類方法將 Intent
傳遞到系統時,系統會運用 Intent
來識別及啟動適當的應用程式元件。使用意圖甚至可讓您的應用程式啟動另一應用程式中的活動。
「明確」的 Intent
可用於啟動特定的 Activity
例項,而「隱含」的 Intent 則用於啟動任何可處理預期動作 (例如「拍照」) 的元件。
本指南的主題說明如何使用 Intent
與其他應用程式進行部分基本互動,例如啟動另一個應用程式、接收來自該應用程式的結果,以及讓應用程式能夠回應其他應用程式的意圖。
Topics
- 將使用者傳送至其他應用程式
- 說明如何建立隱含意圖來啟動其他可執行特定動作的應用程式。
- 取得活動結果
- 說明如何啟動另一活動並取得活動結果。
- 允許其他應用程式啟動您的活動
- 說明如何透過定義意圖篩選器來宣告應用程式可接受的隱含意圖,開放應用程式中的活動供其他應用程式使用。
- 在 Android 上篩選套件瀏覽權限
- 說明如何讓您的應用程式取得其他應用程式的瀏覽權限 (如果這些應用程式未預設為可供瀏覽的話)。僅適用於指定 Android 11 (API 級別 30) 以上版本的應用程式。
- 在套件瀏覽權限有限制的情況下執行常見用途
- 說明數種應用程式互動類型,這些互動類型可能需要您更新應用程式的資訊清單檔案,才能讓您的應用程式取得其他應用程式的瀏覽權限。僅適用於指定 Android 11 (API 級別 30) 以上版本的應用程式。
- 限制載入裝置端 Android 容器
- 說明如何限制 Play 商店應用程式在模擬的 Android 環境應用程式 (也稱為裝置端 Android 容器) 中載入。
如要進一步瞭解本頁所述主題,請參閱以下資源:
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-02-10 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-02-10 (世界標準時間)。"],[],[],null,["# Interact with other apps\n\nAn Android app typically has several [activities](/guide/components/activities). Each activity displays a\nuser interface that lets the user perform a specific task, such as viewing a map or taking a photo.\nTo take the user from one activity to another, your app must use an [Intent](/reference/android/content/Intent) to define your app's \"intent\" to do something. When you pass an\n`Intent` to the system with a method\nsuch as [startActivity()](/reference/android/app/Activity#startActivity(android.content.Intent)),\nthe system uses the `Intent` to identify and start the appropriate app component. Using intents\neven lets your app start an activity that is contained in a separate app.\n\nAn `Intent` can be *explicit* , to start\na specific [Activity](/reference/android/app/Activity) instance,\nor *implicit*, to start any\ncomponent that can handle the intended action, such as \"capture a photo.\"\n\nThe topics in this guide show you how to use an `Intent` to perform some basic\ninteractions with other apps, such as starting another app, receiving a result from that app, and\nmaking your app able to respond to intents from other apps.\n\nTopics\n------\n\n**[Sending the user to another app](/training/basics/intents/sending)**\n: Shows you how to create implicit intents to launch other apps that can perform an\n action.\n\n**[Get a result from an activity](/training/basics/intents/result)**\n: Shows you how to start another activity and receive a result from the activity.\n\n**[Allow other apps to start your activity](/training/basics/intents/filters)**\n: Shows you how to make activities in your app open for use by other apps by defining\n intent filters that declare the implicit intents your app accepts.\n\n**[Package visibility filtering on Android](/training/basics/intents/package-visibility)**\n: Shows you how to make other apps visible to your app if they\n aren't visible by default. Applies only to apps that target Android 11\n (API level 30) or higher.\n\n**[Fulfill common use cases while\nhaving limited package visibility](/training/basics/intents/package-visibility-use-cases)**\n: Shows several types of app interactions that might require you to update\n your app's manifest file so that other apps are visible to your app.\n Applies only to apps that target Android 11 (API level 30) or higher.\n\n**[Limit loading in on-device Android containers](/training/basics/intents/limit-play-loading)**\n: Shows you how to limit your Play Store app from loading in a simulated\n Android environment app, also known as an on-device Android container.\n\nFor additional information about the topics on this page, see the following:\n\n- [Sharing simple data](/training/sharing)\n- [Sharing files](/training/secure-file-sharing)\n- [Integrating Application with Intents](http://android-developers.blogspot.com/2009/11/integrating-application-with-intents.html) blog post\n- [Intents and Intent\n Filters](/guide/components/intents-filters)"]]