1) Intent객체
2) android Component
3) 요소별 Intent 전송 방법
4) Intent로 호출된 컴포넌트에서 전달된 Intent 얻기
5) Android system이 기본제공하는 Activity 호출
class MainActivity : AppCompatActivity(){
val binding by lazy{ ActivityMainBinding.inflate(layoutInflater)}
overrride fun setUpUI(){
binding.btnSMS.setOnClickListener{
//SMS 보내기
val uri = Uri.parse("smsto:" + "01011112222")
val intent = Intent(Intent.ACTION_SENDTO, uri)
intent.putExtri("sms_body", "여기가 문자!!")
startActivity(intent)
}
vinding.btnInternet.setOnClickListener{ //인터넷 이동
//val intent = INtent(Intent.ACITON_DIAL, Uri.parse("tel:" + 114))
//startActivity(intent)
val uri = Url.parse("http://vingageappmaker.tumblr.com/")
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
}
binding.btnMap.setOnClickListener{ // 지도이동
val uri = Uri.parse("geo: 37.5310091, 127.0261659")
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
}
binding.btnMarket.setOnClickListener{ // 마켓으로 이동하기
val uri = Uri.parse("makret://details?id=com.psw.moringcall")
val intent = Intent(Intent.ACTION_VIEW, uri)
startActivity(intent)
}
}
}
1) 새로운 Activity 추가
<!-- AndroidManifest.xml -->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.basic_3_addactivity">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".Main2Activity"></activity>
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
2) Activity 호출
<!-- res.layout.activity_main.xml 에 추가 -->
<Button
android:id="@+id/btnOk"
android:text="Activity 호출"
android:layout_width="wrap_content"
android:layout_height="wrap_content" … />
<TextView
android:textSize="30sp"
android:textColor="#FF0000"
android:text="추가된 Activity"/>
// MainActivity.kt
class MainActivity : AppCompatActivity() {
val binding by lazy { ActivityMainBinding.inflate(layoutInflater) }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(binding.root)
binding.btnOk.setOnClickListener {
val i = Intent(this, Main2Activity::class.java)
startActivity(i)
}
}
}
class
1) 사용자 정의 Toast