안드로이드(Android)/이론
[Android] Intent란?
리안94
2021. 1. 8. 01:26
안드로이드는 4대 컴포넌트(Activity, Service, Broadcast Receiver, Content Provider)가 있는데, 해당 컴포넌트 간의 작업을 수행하기 위한 메세징 객체를 인텐트(Intent)라고 한다. 기본적인 사용 사례는 다음과 같이 3가지가 있다.
- 액티비티 시작
- startActivity()
- 서비스 시작
- startService(), bindService(), jobScheduler
- 브로드캐스트 전달
- sendBroadcast(), sendOrderedBroadcast()
인텐트 유형으로는 명시적인텐트, 암시적 인텐트가 존재한다.
- 명시적 인텐트
- 클래스의 객체나, 컴포넌트 이름을 명시적으로 지정해서 사용하는 것을 말한다.
Intent(this@MainActivity, SecondActivity::class.java).also{
startActivity(it)
}
- 암시적 인텐트
- 호출될 대상의 속성을 지정하였지만, 호출될 대상이 달라질 수 있는 경우를 말한다.
Intent(Intent.ACTION_VIEW, Uri.parse("https://naver.com")).also{
startActivity(it)
}
더 자세히 알고 싶다면, 해당 내용을 확인해보는 것이 좋을 것 같다.
developer.android.com/guide/components/intents-filters?hl=ko
인텐트 및 인텐트 필터 | Android 개발자 | Android Developers
An Intent is a messaging object you can use to request an action from another app component . Although intents facilitate communication between components in several ways, there are three fundamental use cases: An Activity represents a single screen in…
developer.android.com