rijotech rijotech - 1 year ago 77
Android Question

Android can't get Texview content to share intent

I'm working on a share button to share the current item image and content but i cant seen to get the text from the texView id to work on Intent Share.
I was wondering if anybody knows a better method?

btnShare.setOnClickListener(new OnClickListener() {

public void onClick(View arg0) {
View content = findViewById(R.id.imgPreview);

Bitmap bitmap = content.getDrawingCache();
File root = Environment.getExternalStorageDirectory();
File cachePath = new File(root.getAbsolutePath() + "/DCIM/image.jpg");
try {
FileOutputStream ostream = new FileOutputStream(cachePath);
bitmap.compress(CompressFormat.JPEG, 100, ostream);
} catch (Exception e) {

TextView tittle = (TextView) findViewById(R.id.txtText);
TextView txtSubText = (TextView) findViewById(R.id.txtSubText);
TextView txtDescription = (TextView) findViewById(R.id.txtDescription);

Intent share = new Intent(Intent.ACTION_SEND);
share.putExtra(Intent.EXTRA_SUBJECT, tittle);
share.putExtra(Intent.EXTRA_TEXT, txtSubText);
share.putExtra(Intent.EXTRA_TEXT, txtDescription);
share.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(cachePath));
share.putExtra(Intent.EXTRA_TEXT,"This was share via Almas's Delicias");
startActivity(Intent.createChooser(share,"Share via"));

Answer Source

Change this lines of codes:

share.putExtra(Intent.EXTRA_SUBJECT, tittle.getText().toString());
share.putExtra(Intent.EXTRA_TEXT, txtSubText.getText().toString());
share.putExtra(Intent.EXTRA_TEXT, txtDescription.getText().toString());
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download