編輯:關於 Android 開發
在 Android 中,每個元件可以有一個或多個 intent filter。Intent Filter 由 action、data 與 category 三部分構成,於主設定檔 AndroidManifest.xml 中註冊,主要用來指明 Activity、Service、Broadcast Receiver 這三個元件可以回應哪些隱式 Intent。
<intent-filter android:label="Asen's blog">
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.VIEW" />
<action android:name="android.intent.action.EDIT" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.ALTERNATIVE" />
<data android:mimeType="video/mpeg" android:scheme="http".../>
<data android:mimeType="audio/mpeg" android:scheme="content" android:host="com.example.project:200" android:path="/folder/subfolder/etc"/>
</intent-filter>
每個 action、category、data 各佔一行,若有多個就寫多行。
action 與 category:"android.intent.action.MAIN" 與 "android.intent.category.LAUNCHER" 是程式入口點 filter 的必備項目。以短信程式為例,點擊圖示啟動後顯示的第一個畫面(收到的短信列表)就是程式的入口點。此外,除了程式入口點的 filter 之外,其餘所有 intent filter 都必須包含 "android.intent.category.DEFAULT",因為它用來指明元件是否能接收隱式 Intent。
data:由資料類型(mimeType)與 URI 兩部分構成。每個 URI 包含四個屬性參數(scheme、host、port、path),形如 scheme://host:port/path。
例如 content://com.example.project:200/folder/subfolder/etc 中,scheme 是 content、host 是 com.example.project、port 是 200、path 是 folder/subfolder/etc。
Intent Filter 與 Intent 相互配合,實現了 Android 四大元件之間的「信使」功能,讓元件能依宣告的條件自動回應對應的意圖。
Android IPC 入門:用 AIDL 完成跨進程方法調用
Android IPC 入門:用 AIDL 完成跨進程方法調用 IPC 是 Inter-Process Communication 的縮寫,也就是跨進程通信。Androi
Android 對話框實戰:通知、單選、多選與進度框一次搞懂
Android 對話框實戰:通知、單選、多選與進度框一次搞懂 在實際開發中,當應用需要向使用者確認某項操作、展示一段提示資訊,或是回報「正在處理中」的狀態時,對話框(Di
Android WindowManager 窗口管理服務實戰
Android WindowManager 窗口管理服務實戰WindowManager 是 Android 系統中負責窗口管理的底層服務。許多常見 UI 能力,如 Act
在 Android 上使用 qemu-user 執行可執行檔:編譯、部署與 AT_SECURE 錯誤排查
作者:尋禹 @ 阿里聚安全 前言 QEMU 可以解釋執行可執行程式。既然它能解釋執行,那麼它就能知道執行了哪些指令,從而具備了追蹤指令執行的能力。 QEMU 編譯出來的