-> Intent Filter
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
<queries>
<intent>
<action android:name="android.intent.action.SET_ALARM"/>
</intent>
</queries>
<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/Theme.Week7"
tools:targetApi="31">
<activity
android:name=".NothingActivity"
android:exported="false" />
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
package edu.skku.cs.week7
import android.content.Intent
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.EditText
import java.sql.BatchUpdateException
class MainActivity : AppCompatActivity() {
companion object{
const val EXT_HOUR = "extra_key_hour"
const val EXT_MINUTE = "extra_key_minute"
const val EXT_DESCRIPTION = "extra_key_description"
}
override fun onRestart() {
super.onRestart()
val editTextTime = findViewById<EditText>(R.id.editTextTextPersonName)
val editTextDescription = findViewById<EditText>(R.id.editTextTextPersonName2)
editTextTime.text.clear()
editTextDescription.text.clear()
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val btnSecondActivity = findViewById<Button>(R.id.button)
btnSecondActivity.setOnClickListener {
val editTextTime = findViewById<EditText>(R.id.editTextTextPersonName)
val editTextDescription = findViewById<EditText>(R.id.editTextTextPersonName2)
val time = editTextTime.text.toString()
val hour = time!!.split(":")[0]
val minute = time!!.split(":")[1]
val description = editTextDescription.text.toString()
val intent = Intent(this, NothingActivity::class.java).apply {
putExtra(EXT_HOUR, hour)
putExtra(EXT_MINUTE, minute)
putExtra(EXT_DESCRIPTION, description)
}
startActivity(intent)
}
// val btnStart = findViewById<Button>(R.id.buttonBrowse)
// btnStart.setOnClickListener {
// val urlEditText = findViewById<EditText>(R.id.editTextUrl)
// val uri = Uri.parse("https://" + urlEditText.text.toString())
// val webIntent = Intent(Intent.ACTION_VIEW, uri)
// startActivity(webIntent)
// }
}
}
package edu.skku.cs.week7
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.provider.AlarmClock
import android.widget.Button
import android.widget.TextView
import android.widget.Toast
class NothingActivity: AppCompatActivity() {
companion object{
const val EXT_HOUR = "extra_key_hour"
const val EXT_MINUTE = "extra_key_minute"
const val EXT_DESCRIPTION = "extra_key_description"
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.layout)
val hour = intent.getStringExtra(MainActivity.EXT_HOUR)?.toInt()
val minute = intent.getStringExtra(MainActivity.EXT_MINUTE)?.toInt()
val description = intent.getStringExtra(MainActivity.EXT_DESCRIPTION)
val textView = findViewById<TextView>(R.id.textView3)
textView.text = "Do you want to set alarm on time ${hour}:${minute} with description '${description}'?"
val yesButton = findViewById<Button>(R.id.button2)
yesButton.setOnClickListener{
val intent = Intent(AlarmClock.ACTION_SET_ALARM).apply {
putExtra(AlarmClock.EXTRA_MESSAGE, description)
putExtra(AlarmClock.EXTRA_HOUR, hour)
putExtra(AlarmClock.EXTRA_MINUTES, minute)
}
startActivity(intent)
this.finish()
}
val noButton = findViewById<Button>(R.id.button3)
noButton.setOnClickListener {
finish()
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Time"
app:layout_constraintBottom_toBottomOf="@+id/editTextTextPersonName"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/editTextTextPersonName" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
android:text="Description"
app:layout_constraintBottom_toBottomOf="@+id/editTextTextPersonName2"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/editTextTextPersonName2" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:text="Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName2" />
<EditText
android:id="@+id/editTextTextPersonName"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="8dp"
android:ems="10"
android:inputType="time"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="@+id/editTextTextPersonName2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="60dp"
android:layout_marginEnd="8dp"
android:ems="10"
android:hint="description"
android:inputType="textPersonName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/textView2"
app:layout_constraintTop_toBottomOf="@+id/editTextTextPersonName" />
</androidx.constraintlayout.widget.ConstraintLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:text="TextView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:text="OK"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:text="CANCEL"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView3" />
</androidx.constraintlayout.widget.ConstraintLayout>