Skip to content

Instantly share code, notes, and snippets.

@hitesh-dhamshaniya
Created August 23, 2019 10:07
Show Gist options
  • Select an option

  • Save hitesh-dhamshaniya/565c4178526d42fb7b72341d7b0e8819 to your computer and use it in GitHub Desktop.

Select an option

Save hitesh-dhamshaniya/565c4178526d42fb7b72341d7b0e8819 to your computer and use it in GitHub Desktop.
Basic Method require frequently for common functionality.
/**
* @author Hitesh
* @version 1.0
* @since 23-08-2019
*/
class IntentHelper() {
fun launchCall(mActivity: Activity, phoneNumber: String) {
val intent = Intent(Intent.ACTION_DIAL, Uri.parse("tel:$phoneNumber"))
mActivity.startActivity(intent)
}
fun launchMail(mActivity: Activity, emailAddress: String) {
val intent = Intent(Intent.ACTION_SENDTO)
intent.type = "text/html"
intent.putExtra(Intent.EXTRA_EMAIL, "emailaddress@gmail.com")
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject")
intent.putExtra(Intent.EXTRA_TEXT, "I'm email body.")
mActivity.startActivity(Intent.createChooser(intent, "Send Email"))
}
fun launchMap(mActivity: Activity, lat: String, lng: String) {
val intent = Intent(
Intent.ACTION_VIEW,
Uri.parse("geo:0,0?q=$lat,$lng (Mas Insurance Group)")
)
mActivity.startActivity(intent)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment