【问题标题】:Send sms from text view with click button [duplicate]使用单击按钮从文本视图发送短信[重复]
【发布时间】:2018-01-03 13:49:59
【问题描述】:

我想知道如何通过一个按钮发送短信获取textview信息,我不需要接收消息,只需单击特定号码的按钮发送textview信息

【问题讨论】:

标签: android android-intent android-activity


【解决方案1】:

到目前为止,您做了什么?我建议使用一个隐式意图,在单击按钮时触发手机中的短信客户端,如下所示:

Uri smsUri = Uri.parse("tel:123456");
Intent intent = new Intent(Intent.ACTION_VIEW, smsUri);
intent.putExtra("sms_body", "sms text");
intent.setType("vnd.android-dir/mms-sms"); 
startActivity(intent);

"sms text" 应该是您的 textView 文本。你可以这样做

yourTextView.getText().toString();

【讨论】:

  • 按钮 sendtext = (Button) findViewById(R.id.sendtext); sendtext.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Uri smsUri = Uri.parse("tek:999"); Intent intent = new Intent(Intent.ACTION_VIEW,smsUri); intent. putExtra("sms_body", textViewew1.getText().toString()); intent.setType("vnd.android-dir/mms-sms"); startActivity(intent); } }); } }
  • 我这样做了,但不起作用我点击de按钮时收到错误
  • 好的,我解决了问题,非常感谢
  • 别担心,你可以接受正确的答案
  • 当然,但在我想知道如何分离不同的文本视图之前,因为当我在手机上看到 all.is together 的消息时,我必须使用 /n 或类似的东西?
猜你喜欢
  • 2014-02-04
  • 1970-01-01
  • 2021-07-25
  • 2015-05-21
  • 1970-01-01
  • 1970-01-01
  • 2012-05-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多