Search code examples
androidactionsharesend

Intent.ACTION_SEND to share text worked well before, but failed now


I used the same code below to share text to Line, Wechat,... It worked well before, but now it transfers nothing to the other apps. Though I trace to see everything going the same and correctly in the sendIntent(below). Does anyone have similar experiences? Thanks in advance for any suggestion!


    FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
    fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            //Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)  .setAction("Action", null).show();
            Intent sendIntent = new Intent();
            sendIntent.setAction(Intent.ACTION_SEND);
            sendIntent.putExtra(Intent.EXTRA_TEXT, editText.getText()); //EditText..getText() is Editable, still can get string
            sendIntent.setType("text/plain");
            startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
        }
    });

Solution

  •  FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
     fab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
              Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
              sharingIntent.setType("text/plain");              
              sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject here");
              sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, voiceTextView.getText());
              startActivity(Intent.createChooser(sharingIntent, "Sharing Option"));
    
         }
    });