В блоге:

2010-01-20

HTC Hero (Android 1.5): Intent

В ОС Android применен весьма интересный подход с Intent:
===
Intents and Intent Filters

Three of the core components of an application — activities, services, and broadcast receivers — are activated through messages, called intents. Intent messaging is a facility for late run-time binding between components in the same or different applications. The intent itself, an Intent object, is a passive data structure holding an abstract description of an operation to be performed — or, often in the case of broadcasts, a description of something that has happened and is being announced.
...
It then describes the rules Android uses to map intents to components — how it resolves which component should receive an intent message. For intents that don't explicitly name a target component, this process involves testing the Intent object against intent filters associated with potential targets.
===

Например, открываем картинку из клиента GMail. В logcat видно: Starting activity: Intent { action=android.intent.action.VIEW data=file:///sdcard/download/downloadfile-4.jpeg type=image/jpeg flags=0x80001 comp={android/com.android.internal.app.ResolverActivity} }, а пользователь видит диалог выбора нужного Activity:



Выбираем встроенный смотрелку. Это отмечается в logcat как: Starting activity: Intent { action=android.intent.action.VIEW data=file:///sdcard/download/downloadfile-4.jpeg type=image/jpeg flags=0x3880001 comp={com.htc.album/com.htc.album.ViewImage} }

Всплывает окно просмотра.

Аналогичный диалог пользователь видит, например, при наличии двух или более браузеров в системе и попытке открыть ссылку:



Еще по этой теме:
Изображения из альбомов:

0 comments:

Post a Comment

Blog Archive