Intent.ACTION_SEND分享文本之前运作良好,但现在失败了

时间:2017-05-31 09:02:22

标签: android action share send

我使用下面相同的代码与Line,Wechat,...分享文本 之前它运作良好,但现在它没有转移到其他应用程序。虽然我追踪到sendIntent(下面)中看到的一切都是正确的。有没有人有类似的经历?

提前感谢任何建议!

    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, voiceTextView.getText()); //EditText..getText() is Editable, still can get string
            sendIntent.setType("text/plain");
            startActivity(Intent.createChooser(sendIntent, getResources().getText(R.string.send_to)));
        }
    });

1 个答案:

答案 0 :(得分:2)

 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"));

     }
});