package com.example.deeplinkdemo
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
class DeepLinkDemoScreen : AppCompatActivity() {
private lateinit var messageTextView: TextView
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_deep_link_demo_screen)
messageTextView = findViewById(R.id.messageTextView)
val data: Uri? = intent?.data
if (data != null && data.scheme == "myapp" && data.host == "showmessage") {
val message = data.getQueryParameter("msg") ?: "No message found"
messageTextView.text = message
} else {
messageTextView.text = "Welcome! Open this screen via a deep link."
}
}
}We check if the intent has data (a Uri). Then we verify the scheme is 'myapp' and the host is 'showmessage' to confirm it's our deep link. We extract the 'msg' query parameter from the Uri and display it in the TextView. If no deep link or message is found, we show a default welcome message.