按发送时,短信意图没有关闭

时间:2018-12-17 17:38:56

标签: java android

getData(): Observable<string[]> {
  return this._userService.getUser()
    .pipe(
      switchMap(userInfo=> {
         return this.getPrivateGroup();
      }),
      catchError(this.someErrorHandler)
    );
}

如何使这条线正常工作?

1 个答案:

答案 0 :(得分:0)

此代码将在您单击按钮时发送短信,而无需转到消息框

String sendMessage = "Your Message";
                SmsManager sms = SmsManager.getDefault();
                PendingIntent sentPI;
                String SENT = "SMS_SENT";
                sentPI = PendingIntent.getBroadcast(MainActivity.this, 0, new Intent(SENT), 0);
                sms.sendTextMessage("MOBILE NUMBER", null, sendMessage, sentPI, null);

而且Yaa不会忘记在清单中添加权限

<uses-permission android:name="android.permission.SEND_SMS"/>