• android:sms


    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >
    
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/numberinput" />
    
        <EditText
            android:id="@+id/number"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:inputType="number" />
    
        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/contentsms" />
    
        <EditText
            android:id="@+id/content"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:minLines="3"
            android:inputType="text" />
    
        <Button
            android:id="@+id/send"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/button" />
    
    </LinearLayout>


    package com.example.sms;
    
    import java.util.List;
    
    import android.app.Activity;
    import android.os.Bundle;
    import android.telephony.SmsManager;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.Toast;
    
    public class SMSActivity extends Activity {
    
    	@Override
    	protected void onCreate(Bundle savedInstanceState) {
    		super.onCreate(savedInstanceState);
    		setContentView(R.layout.activity_main);
    		final EditText text01 = (EditText) this.findViewById(R.id.number);
    		final EditText text02 = (EditText) this.findViewById(R.id.content);
    		Button btnSend = (Button) this.findViewById(R.id.send);
    		btnSend.setOnClickListener(new View.OnClickListener() {
    			@Override
    			public void onClick(View v) {
    				String mobile = text01.getText().toString();
    				String content = text02.getText().toString();
    				SmsManager smsManager = SmsManager.getDefault();
    				List<String> texts = smsManager.divideMessage(content);
    				for (String text : texts) {
    					smsManager.sendTextMessage(mobile, null, text, null, null);
    				}
    				Toast.makeText(SMSActivity.this, "success", Toast.LENGTH_LONG).show();
    			}
    		});
    	}
    
    }
    


  • 相关阅读:
    Memcached
    sleep和wait的区别
    基于.net Core+EF Core项目的搭建(一)
    .net Core中使用AutoMapper
    发布.net core应用程序并部署到IIS上
    IoC原理-使用反射/Emit来实现一个最简单的IoC容器
    浅谈(IOC)依赖注入与控制反转(DI)
    使用MD5加密字符串
    C#中HttpWebRequest的用法详解
    学习memcached的一个网站
  • 原文地址:https://www.cnblogs.com/javafly/p/6037237.html
Copyright © 2020-2023  润新知