Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vicky7230/f9389a9519730b7434512221ab149444 to your computer and use it in GitHub Desktop.
Save vicky7230/f9389a9519730b7434512221ab149444 to your computer and use it in GitHub Desktop.
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val button = findViewById(R.id.button)
val editText = findViewById(R.id.editText) as EditText
button.setOnClickListener {
val intent = Intent("com.google.android.instantapps.START")
intent.addCategory(Intent.CATEGORY_BROWSABLE)
// Instant apps need to end with a / or the urls don't work
var text = editText.text.toString()
if (!text.endsWith("/")) {
text += "/"
}
intent.data = Uri.parse(text)
startActivity(intent)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment