zoukankan      html  css  js  c++  java
  • 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();
    			}
    		});
    	}
    
    }
    


  • 相关阅读:
    mysql5.7.22安装步骤
    idea 配置http代理
    大话设计模式之类与类之间的关系读后感
    大话设计模式之工厂方法模式读后感
    rabbitmq+java入门(五)Topic
    rabbitmq+java入门(四)routing
    rabbitmq+java入门(二) 工作队列
    rabbitmq+java入门(三)exchange的使用
    rabbitmq+java入门(一)hello world
    idea+jrebel+springboot热部署
  • 原文地址:https://www.cnblogs.com/javafly/p/6037237.html
Copyright © 2011-2022 走看看