Last active
April 22, 2019 08:42
-
-
Save tizisdeepan/52962b79883696dfedde7e13f0614806 to your computer and use it in GitHub Desktop.
A Clip Board utility for copying contents to Clip Board.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.ClipData | |
import android.content.ClipboardManager | |
import android.content.Context | |
import android.widget.Toast | |
object ClipBoardManager { | |
fun copy(ctx: Context, text: String, message: String = "") { | |
val myClipboard = ctx.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager | |
val myClip = ClipData.newPlainText(message, text) | |
myClipboard.primaryClip = myClip | |
if (message.isNotEmpty() && text.isNotEmpty()) Toast.makeText(ctx, message, Toast.LENGTH_SHORT).show() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
USAGE