Skip to content

Instantly share code, notes, and snippets.

@hetang
hetang / open_email_app.kt
Last active October 10, 2023 16:37
Open Email inbox or compose view in Android
/**
* This function open email compose view and post HTML body
**/
// val body = Html.fromHtml(fragment.resources.getString(R.string.email_body))
fun navToEmailCompose(email: String, subject: String, body: String) {
val intent = Intent(Intent.ACTION_SENDTO,
Uri.parse("mailto:${email}"))
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject)
intent.putExtra(android.content.Intent.EXTRA_TEXT, body)
startActivity(Intent.createChooser(intent, "Email"))
@hetang
hetang / context-capability.markdown
Last active April 10, 2018 21:21
Context Scope and its capability in Android

Context Capabilities

Application Activity Service ContentProvider BroadcastReceiver
Show a Dialog NO YES NO NO NO
Start an Activity NO1 YES NO1 NO1 NO
Layout Inflation NO2 YES NO2 NO2 NO
Start a Service YES YES YES YES YES
Bind to a Service YES YES YES YES NO
Send a Broadcast YES YES YES YES YES
@hetang
hetang / git-branches-owner.sh
Created April 10, 2018 06:04
Get List of Git Branches & its owner Info.
git fetch --prune
for branch in $(git branch -r --no-merged origin/staging | sed s/origin\\///g | grep -v HEAD); do
printf "%-32s %s\n" "$(git show -s --format=%an origin/$branch)" $branch;
done | sort