Skip to content

Instantly share code, notes, and snippets.

@nishtahir
Created June 1, 2017 12:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nishtahir/47bf8900774b5f2ea9e8bb1ac88a316f to your computer and use it in GitHub Desktop.
Save nishtahir/47bf8900774b5f2ea9e8bb1ac88a316f 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