Cast copied text to string before sending share intent
EditText#getText returns an Editable (editable buffer), not a string. This is serializable, so it can be put into the intent without error, but trying to retrieve it with intent.getStringExtra(Intent.EXTRA_TEXT) returns null. Casting to a string fixes this problem and allows destination apps to correctly read the copied (and edited) text. Bug: 227107111 Fix: 227107111 Test: verified that sharing to e.g. Chat copies the text into the send box (prior to change it would open the app but copy no text). Change-Id: I3052677ae65556949351e9d112e81d38dc209bc9
This commit is contained in:
@@ -95,7 +95,7 @@ public class EditTextActivity extends Activity
|
||||
private void share() {
|
||||
Intent sendIntent = new Intent();
|
||||
sendIntent.setAction(Intent.ACTION_SEND);
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, mEditText.getText());
|
||||
sendIntent.putExtra(Intent.EXTRA_TEXT, mEditText.getText().toString());
|
||||
sendIntent.setType("text/plain");
|
||||
|
||||
Intent shareIntent = Intent.createChooser(sendIntent, null);
|
||||
|
||||
Reference in New Issue
Block a user