Text copy and share Android Java
Text copy and share Android Java:
copy.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
ClipData clipData = ClipData.newPlainText("nonsense_data",
text_name.getText().toString());
clipboardManager.setPrimaryClip(clipData);
Toast.makeText(premomoy.this, "Copied", Toast.LENGTH_SHORT).show();
}
});
share.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String textToShare = text_name.getText().toString();
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtra(Intent.EXTRA_TEXT, textToShare);
sendIntent.setType("text/plain");
Intent shareIntent = Intent.createChooser(sendIntent, null);
startActivity(shareIntent);
}
});
Comments
Post a Comment