Reputation:
In My Block Of Code i am Suffering from the Error "Cannot resolve method 'putExtra(java.lang.String, android.widget.TextView)'". Ive Tried a few Things However i cannot get this fixed. Does Anyone Know what i could do to fix this, or an alternative piece of Code I Could Use?
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setPackage("com.whatsapp");
shareIntent.putExtra(Intent.EXTRA_STREAM,uri);
shareIntent.putExtra(Intent.EXTRA_TEXT, (TextView)findViewById(R.id.txt_message));
shareIntent.setType("text/plain");
Upvotes: 1
Views: 1314
Reputation: 386
If you try to put text from TextView (txt_message) to bundle - just put text from it like this (not a TextView):
TextView txt_message = (TextView) findViewById(R.id.txt_message);
String text = txt_message.getText().toString();
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setPackage("com.whatsapp");
shareIntent.putExtra(Intent.EXTRA_STREAM,uri);
shareIntent.putExtra(Intent.EXTRA_TEXT, text);
shareIntent.setType("text/plain");
Upvotes: 1
Reputation: 209
Add this code after intent:
Bundle extras = shareIntent.getExtras();
String exampleString = extras.getString(ProjectManager.ID);
Upvotes: 0