jc01rho의 일상잡다

Android Intent 정리 본문

컴퓨터/안드로이드

Android Intent 정리

jc01rho 2011.09.24 00:44

Android를 공부하면서 Intent를 다음과 같이 정리해 보았다. Android에서는 Intent와 View가 가장 복잡한 것 같다.

Intent

public class android.content.Intent implements Parcelable 

  • 정의
원하는 실제 행동을 호출할 때 사용하는 객체
애플리케이션에서 다른 모듈의 기능을 호출할 때 사용하는 객체
Intent 핸들러(Activity, Service, BroadcastReceiver)에 의해서 처리됨

Android Intent

  • 구성
Component가 Data와 Type로 지정된 대상에 대해 Category와 Action으로 지정된 행위를 한다. 추가적인 정보는 Extras로 제공 한다.
Category
  • 인텐트의 분류로 여러 값을 가질 수 있음
  • Category가 있고 Action이 없을 경우 모든 Action이 매핑됨
CATEGORY_DEFAULT = "android.intent.category.DEFAULT";
CATEGORY_BROWSABLE = "android.intent.category.BROWSABLE";
CATEGORY_ALTERNATIVE = "android.intent.category.ALTERNATIVE";
CATEGORY_SELECTED_ALTERNATIVE = "android.intent.category.SELECTED_ALTERNATIVE";
CATEGORY_TAB = "android.intent.category.TAB";
CATEGORY_LAUNCHER = "android.intent.category.LAUNCHER";
CATEGORY_INFO = "android.intent.category.INFO";
CATEGORY_HOME = "android.intent.category.HOME";
CATEGORY_PREFERENCE = "android.intent.category.PREFERENCE";
CATEGORY_DEVELOPMENT_PREFERENCE = "android.intent.category.DEVELOPMENT_PREFERENCE";
CATEGORY_EMBED = "android.intent.category.EMBED";
CATEGORY_MONKEY = "android.intent.category.MONKEY";
CATEGORY_TEST = "android.intent.category.TEST";
CATEGORY_UNIT_TEST = "android.intent.category.UNIT_TEST";
CATEGORY_SAMPLE_CODE = "android.intent.category.SAMPLE_CODE";
CATEGORY_OPENABLE = "android.intent.category.OPENABLE";
CATEGORY_FRAMEWORK_INSTRUMENTATION_TEST = "android.intent.category.FRAMEWORK_INSTRUMENTATION_TEST";
CATEGORY_CAR_DOCK = "android.intent.category.CAR_DOCK";
CATEGORY_DESK_DOCK = "android.intent.category.DESK_DOCK";
Action
  • 인텐트의 액션
  • Category가 없고 Action이 있을 경우, Category가 없는 Action만 매핑됨
ACTION_MAIN = "android.intent.action.MAIN";
ACTION_VIEW = "android.intent.action.VIEW";
ACTION_DEFAULT = "android.intent.action.VIEW";
ACTION_ATTACH_DATA = "android.intent.action.ATTACH_DATA";
ACTION_EDIT = "android.intent.action.EDIT";
ACTION_INSERT_OR_EDIT = "android.intent.action.INSERT_OR_EDIT";
ACTION_PICK = "android.intent.action.PICK";
ACTION_CREATE_SHORTCUT = "android.intent.action.CREATE_SHORTCUT";
ACTION_CHOOSER = "android.intent.action.CHOOSER";
ACTION_GET_CONTENT = "android.intent.action.GET_CONTENT";
ACTION_DIAL = "android.intent.action.DIAL";
ACTION_CALL = "android.intent.action.CALL";
ACTION_SENDTO = "android.intent.action.SENDTO";
ACTION_SEND = "android.intent.action.SEND";
ACTION_SEND_MULTIPLE = "android.intent.action.SEND_MULTIPLE";
ACTION_ANSWER = "android.intent.action.ANSWER";
ACTION_INSERT = "android.intent.action.INSERT";
ACTION_DELETE = "android.intent.action.DELETE";
ACTION_RUN = "android.intent.action.RUN";
ACTION_SYNC = "android.intent.action.SYNC";
ACTION_PICK_ACTIVITY = "android.intent.action.PICK_ACTIVITY";
ACTION_SEARCH = "android.intent.action.SEARCH";
ACTION_SYSTEM_TUTORIAL = "android.intent.action.SYSTEM_TUTORIAL";
ACTION_WEB_SEARCH = "android.intent.action.WEB_SEARCH";
ACTION_ALL_APPS = "android.intent.action.ALL_APPS";
ACTION_SET_WALLPAPER = "android.intent.action.SET_WALLPAPER";
ACTION_BUG_REPORT = "android.intent.action.BUG_REPORT";
ACTION_FACTORY_TEST = "android.intent.action.FACTORY_TEST";
ACTION_CALL_BUTTON = "android.intent.action.CALL_BUTTON";
ACTION_VOICE_COMMAND = "android.intent.action.VOICE_COMMAND";
ACTION_SEARCH_LONG_PRESS = "android.intent.action.SEARCH_LONG_PRESS";
ACTION_POWER_USAGE_SUMMARY = "android.intent.action.POWER_USAGE_SUMMARY";
ACTION_SCREEN_OFF = "android.intent.action.SCREEN_OFF";
ACTION_SCREEN_ON = "android.intent.action.SCREEN_ON";
ACTION_USER_PRESENT = "android.intent.action.USER_PRESENT";
ACTION_TIME_TICK = "android.intent.action.TIME_TICK";
ACTION_TIME_CHANGED = "android.intent.action.TIME_SET";
ACTION_DATE_CHANGED = "android.intent.action.DATE_CHANGED";
ACTION_TIMEZONE_CHANGED = "android.intent.action.TIMEZONE_CHANGED";
ACTION_BOOT_COMPLETED = "android.intent.action.BOOT_COMPLETED";
ACTION_CLOSE_SYSTEM_DIALOGS = "android.intent.action.CLOSE_SYSTEM_DIALOGS";
ACTION_PACKAGE_INSTALL = "android.intent.action.PACKAGE_INSTALL";
ACTION_PACKAGE_ADDED = "android.intent.action.PACKAGE_ADDED";
ACTION_PACKAGE_REPLACED = "android.intent.action.PACKAGE_REPLACED";
ACTION_PACKAGE_REMOVED = "android.intent.action.PACKAGE_REMOVED";
ACTION_PACKAGE_CHANGED = "android.intent.action.PACKAGE_CHANGED";
ACTION_PACKAGE_RESTARTED = "android.intent.action.PACKAGE_RESTARTED";
ACTION_PACKAGE_DATA_CLEARED = "android.intent.action.PACKAGE_DATA_CLEARED";
ACTION_UID_REMOVED = "android.intent.action.UID_REMOVED";
ACTION_WALLPAPER_CHANGED = "android.intent.action.WALLPAPER_CHANGED";
ACTION_CONFIGURATION_CHANGED = "android.intent.action.CONFIGURATION_CHANGED";
ACTION_LOCALE_CHANGED = "android.intent.action.LOCALE_CHANGED";
ACTION_BATTERY_CHANGED = "android.intent.action.BATTERY_CHANGED";
ACTION_BATTERY_LOW = "android.intent.action.BATTERY_LOW";
ACTION_BATTERY_OKAY = "android.intent.action.BATTERY_OKAY";
ACTION_POWER_CONNECTED = "android.intent.action.ACTION_POWER_CONNECTED";
ACTION_POWER_DISCONNECTED = "android.intent.action.ACTION_POWER_DISCONNECTED";
ACTION_SHUTDOWN = "android.intent.action.ACTION_SHUTDOWN";
ACTION_DEVICE_STORAGE_LOW = "android.intent.action.DEVICE_STORAGE_LOW";
ACTION_DEVICE_STORAGE_OK = "android.intent.action.DEVICE_STORAGE_OK";
ACTION_MANAGE_PACKAGE_STORAGE = "android.intent.action.MANAGE_PACKAGE_STORAGE";
ACTION_UMS_CONNECTED = "android.intent.action.UMS_CONNECTED";
ACTION_UMS_DISCONNECTED = "android.intent.action.UMS_DISCONNECTED";
ACTION_MEDIA_REMOVED = "android.intent.action.MEDIA_REMOVED";
ACTION_MEDIA_UNMOUNTED = "android.intent.action.MEDIA_UNMOUNTED";
ACTION_MEDIA_CHECKING = "android.intent.action.MEDIA_CHECKING";
ACTION_MEDIA_NOFS = "android.intent.action.MEDIA_NOFS";
ACTION_MEDIA_MOUNTED = "android.intent.action.MEDIA_MOUNTED";
ACTION_MEDIA_SHARED = "android.intent.action.MEDIA_SHARED";
ACTION_MEDIA_BAD_REMOVAL = "android.intent.action.MEDIA_BAD_REMOVAL";
ACTION_MEDIA_UNMOUNTABLE = "android.intent.action.MEDIA_UNMOUNTABLE";
ACTION_MEDIA_EJECT = "android.intent.action.MEDIA_EJECT";
ACTION_MEDIA_SCANNER_STARTED = "android.intent.action.MEDIA_SCANNER_STARTED";
ACTION_MEDIA_SCANNER_FINISHED = "android.intent.action.MEDIA_SCANNER_FINISHED";
ACTION_MEDIA_SCANNER_SCAN_FILE = "android.intent.action.MEDIA_SCANNER_SCAN_FILE";
ACTION_MEDIA_BUTTON = "android.intent.action.MEDIA_BUTTON";
ACTION_CAMERA_BUTTON = "android.intent.action.CAMERA_BUTTON";
ACTION_GTALK_SERVICE_CONNECTED = "android.intent.action.GTALK_CONNECTED";
ACTION_GTALK_SERVICE_DISCONNECTED = "android.intent.action.GTALK_DISCONNECTED";
ACTION_INPUT_METHOD_CHANGED = "android.intent.action.INPUT_METHOD_CHANGED";
ACTION_AIRPLANE_MODE_CHANGED = "android.intent.action.AIRPLANE_MODE";
ACTION_PROVIDER_CHANGED = "android.intent.action.PROVIDER_CHANGED";
ACTION_HEADSET_PLUG = "android.intent.action.HEADSET_PLUG";
ACTION_NEW_OUTGOING_CALL = "android.intent.action.NEW_OUTGOING_CALL";
ACTION_REBOOT = "android.intent.action.REBOOT";
ACTION_DOCK_EVENT = "android.intent.action.DOCK_EVENT";
Data
  • 작업 요청 URI
  • 종류 1 : scheme, authority, path
  • 예) weather://com.msi.manning/loc?zip=12345
  • 종류 2 : MIME 형식, Content Provider와 연계됨
  • 예) content://com.google.provider.NotePad/notes
  • Scheme가 있고 Type이 없으면, 모든 Type이 매핑됨
  • Scheme가 없고 Type이 있으면, 모든 Scheme가 매핑됨
  • Scheme가 없고 Type이 없으면, 매핑되지 않음
Type
  • MIME 타입
Component
Extras
  • 추가 데이터, Bundle
  • 인텐트 선언
  • 명시적 선언 : new Intent(Context packageContext, Class cls)
  • 묵시적 선언 : new Intent(String action, Uri uri)
  • 인텐트 핸들러
Activity
  • android.content.Context.startActivity(Intent intent)
Service
  • android.content.Context.startService(Intent intent)
  • android.content.Context.bindService(Intent intent, ServiceConnection serviceconnection, int i)
BroadcastReceiver
  • android.content.Context.sendBroadcast(Intent intent)
  • android.content.Context.sendStickyBroadcast(Intent intent)
  • android.content.Context.sendOrderedBroadcast(Intent intent, String receiverPermission)
  • android.content.BroadcastReceiver.onReceive(Context context, Intent intent)
  • IntentFilter
  • AndroidManifest.xml
Intent intent = new Intent(Constants.INTENT_ACTION_VIEW_LIST);
startActivity(intent);

<activity android:name="ReviewList"> 또는 <service> 또는 <receiver>
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="com.msi.manning.restaurant.VIEW_LIST" />
<data android:scheme="weather" android:host="com.msi.manning" />
</intent-filter>
</activity>
0 Comments
댓글쓰기 폼
Prev 1 2 3 4 5 6 7 Next