Why doesn't this code send anything to other Applications ? It just opens other applications

烈酒焚心 提交于 2019-12-11 19:57:50

问题


I have this code for selecting a textView and copying to clipboard :

txt=(TextView)findViewById(R.id.textView1);
        int startIndex = txt.getSelectionStart();
        int endIndex = txt.getSelectionEnd();
        final String stringYouExtracted = txt.getText().toString().substring(startIndex, endIndex);
        ClipboardManager clipboard = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
        clipboard.setText(stringYouExtracted);

I want put a button that when I press it , sends text that I have selected it in previous code , I have this code too :

btn.setOnClickListener(new OnClickListener() {
   public void onClick(View arg0) {
      Intent sendIntent = new Intent();
      sendIntent.setAction(Intent.ACTION_SEND);
      sendIntent.putExtra(Intent.EXTRA_TEXT, stringYouExtracted);
      sendIntent.setType("text/plain");
      startActivity(sendIntent);
   }
});

Every thing is ok but when I press the button and choose other application for example viber ...... viber just opens and This Code Doesn't Sending Anything to viber .... It can just open viber ........... What should I do ????

来源:https://stackoverflow.com/questions/22756458/why-doesnt-this-code-send-anything-to-other-applications-it-just-opens-other

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!