-
Notifications
You must be signed in to change notification settings - Fork 398
/
MainActivity.kt
32 lines (25 loc) · 1000 Bytes
/
MainActivity.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package com.google.firebase.dynamicinvites.kotlin.view
import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.google.firebase.dynamicinvites.R
import com.google.firebase.dynamicinvites.kotlin.util.DynamicLinksUtil
import kotlinx.android.synthetic.main.activity_main.buttonShare
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
buttonShare.setOnClickListener {
onShareClicked()
}
}
// [START ddl_on_share_clicked]
private fun onShareClicked() {
val link = DynamicLinksUtil.generateContentLink()
val intent = Intent(Intent.ACTION_SEND)
intent.type = "text/plain"
intent.putExtra(Intent.EXTRA_TEXT, link.toString())
startActivity(Intent.createChooser(intent, "Share Link"))
}
// [END ddl_on_share_clicked]
}